dharma.core package¶
Submodules¶
-
class
dharma.core.dharma.
DharmaMachine
(prefix='', suffix='', template='')¶ Bases:
object
-
add_section_object
()¶
-
calculate_leaf_path
(leaf, reverse_xref)¶
-
calculate_leaf_paths
()¶ Build map of reverse xrefs then traverse backwards marking path to leaf for all leaves.
-
generate_content
()¶ Generates a test case as a string.
-
generate_testcases
(path, filetype, count)¶ Writes out generated test cases to the provided path.
-
handle_assign_level
(assign)¶
-
handle_const
(const, value)¶
-
handle_empty_line
()¶
-
handle_top_level
(ident)¶
-
id
()¶
-
parse_assign_value
(tokens)¶
-
parse_assign_variable
(tokens)¶ - Example:
- tokens
- dharma.String: ‘let ‘, dharma.ElementXRef: ‘GrammarNS:<VarName>’, dharma.String: ‘= new ‘, dharma.ValueXRef: ‘GrammarNS:<ValueName>’
-
parse_assign_variance
(tokens)¶
-
parse_line
(line)¶
-
parse_xrefs
(token)¶ Search token for +value+ and !variable! style references. Be careful to not xref a new variable.
-
process_grammars
(grammars)¶ Process provided grammars by parsing them into Python objects.
-
process_settings
(settings)¶ A lazy way of feeding Dharma with configuration settings.
-
propagate_leaf
(leaf, obj, node_seen, depth, reverse_xref)¶
-
resolve_xref
()¶
-
set_namespace
(name)¶
-
-
class
dharma.core.dharma.
DharmaObject
(ident, machine)¶ Bases:
list
Base object of which Dharma section classes inherit from.
-
static
eval
(tokens, state)¶
-
id
()¶
-
static
-
class
dharma.core.dharma.
DharmaValue
(ident, machine)¶ Bases:
dharma.core.dharma.DharmaObject
Dharma class which manages the |value| section of a grammar.
-
append
(value)¶ Append object to the end of the list.
-
generate
(state)¶
-
n_xrefs
(value)¶
-
-
class
dharma.core.dharma.
DharmaVariable
(ident, machine)¶ Bases:
dharma.core.dharma.DharmaObject
Dharma class which manages the |variable| section of a grammar.
-
clear
()¶ Remove all items from list.
-
generate
(state)¶ Return a random variable if any, otherwise create a new default variable.
-
-
class
dharma.core.dharma.
DharmaVariance
(ident, machine)¶ Bases:
dharma.core.dharma.DharmaObject
Dharma class which manages the |variance| section of a grammar.
-
generate
(state)¶
-
-
class
dharma.core.dharma.
ElementXRef
(value, parent)¶ Bases:
object
Generator class for @value@ cross references.
-
generate
(state)¶
-
-
class
dharma.core.dharma.
GenState
¶ Bases:
object
-
class
dharma.core.dharma.
String
(value, parent)¶ Bases:
object
Generator class basic strings which need no further evaluation.
-
generate
(state)¶
-
-
class
dharma.core.dharma.
ValueXRef
(value, parent)¶ Bases:
object
Generator class for +value+ cross references.
-
generate
(state)¶
-
-
class
dharma.core.dharma.
VariableXRef
(value, parent)¶ Bases:
object
Generator class for !variable! cross references.
-
generate
(state)¶
-
-
class
dharma.core.extensions.
DharmaConst
¶ Bases:
object
Configuration settings for the Dharma generator.
-
LEAF_TRIGGER
= 256¶
-
MAX_REPEAT_POWER
= 12¶
-
URI_TABLE
= {}¶
-
VARIABLE_MAX
= 4¶
-
VARIABLE_MIN
= 1¶
-
VARIANCE_MAX
= 8¶
-
VARIANCE_MIN
= 1¶
-
VARIANCE_TEMPLATE
= '%s'¶
-
-
class
dharma.core.extensions.
MetaBlock
(path, parent)¶ Bases:
object
Grammar extension which loads code fragments from a file into the grammar.
-
generate
(state)¶
-
-
class
dharma.core.extensions.
MetaChoice
(choices, parent)¶ Bases:
object
Grammar extension method which chooses an item out of a list randomly.
-
generate
(state)¶
-
-
class
dharma.core.extensions.
MetaRange
(a, b, parent)¶ Bases:
object
Grammar extension method which generates a random value between a range of values |a| and |b|.
-
generate
(state)¶
-
-
class
dharma.core.extensions.
MetaRepeat
(repeat, separator, nodups, parent)¶ Bases:
object
Grammar extension method which repeats an arbitrary expression.
-
generate
(state)¶
-
-
class
dharma.core.extensions.
MetaURI
(path, parent)¶ Bases:
object
Grammar extension which loads a random file URI into the generated code.
-
generate
(state)¶
-
-
class
dharma.core.websocket.
BaseWebSocketHandler
(request, client_address, server)¶ Bases:
socketserver.BaseRequestHandler
Base class for WebSocket server.
-
REQUEST_TIMEOUT
= 0.01¶
-
finish
()¶
-
handle
()¶
-
on_close
()¶
-
on_message
(message)¶
-
on_pong
()¶
-
open
()¶
-
ping
()¶
-
should_close
()¶ When this returns true, the message loop will exit.
-
write_message
(message, binary=False)¶
-