This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html><head><title>PyDwarf docs</title><style>pre { background-color:#ddd; color:#113 }</style></head><body><h1style="font-size: 50; color: #800">Warning: This is a shitty WIP.</h1><h1>pydwarf.session</h1><p><b>__init__</b><br><pre>None</pre></p><p><b>eval</b><br><pre>None</pre></p><p><b>failed</b><br><pre>None</pre></p><p><b>funcs</b><br><pre>None</pre></p><p><b>handle</b><br><pre>None</pre></p><p><b>handleall</b><br><pre>None</pre></p><p><b>inlist</b><br><pre>None</pre></p><p><b>successful</b><br><pre>None</pre></p><h1>pydwarf.urist</h1><p><b>__call__</b><br><pre>None</pre></p><p><b>__hash__</b><br><pre>None</pre></p><p><b>__init__</b><br><pre>None</pre></p><p><b>allregistered</b><br><pre>None</pre></p><p><b>cullcandidates</b><br><pre>None</pre></p><p><b>cullcandidates_compatibility</b><br><pre>None</pre></p><p><b>cullcandidates_dependency</b><br><pre>None</pre></p><p><b>cullcandidates_duplicates</b><br><pre>None</pre></p><p><b>cullcandidates_match</b><br><pre>None</pre></p><p><b>depsatisfied</b><br><pre>None</pre></p><p><b>doc</b><br><pre>Make a pretty metadata string.</pre></p><p><b>doclist</b><br><pre>None</pre></p><p><b>forfunc</b><br><pre>None</pre></p><p><b>get</b><br><pre>None</pre></p><p><b>getfn</b><br><pre>None</pre></p><p><b>getname</b><br><pre>None</pre></p><p><b>getregistered</b><br><pre>None</pre></p><p><b>info</b><br><pre>None</pre></p><p><b>list</b><br><pre>None</pre></p><p><b>matches</b><br><pre>None</pre></p><p><b>meta</b><br><pre>None</pre></p><p><b>splitname</b><br><pre>None</pre></p><h1>raws.boolfilter</h1><p><b>__init__</b><br><pre>None</pre></p><p><b>all</b><br><pre>None</pre></p><p><b>any</b><br><pre>None</pre></p><p><b>basematch</b><br><pre>None</pre></p><p><b>invert</b><br><pre>None</pre></p><p><b>match</b><br><pre>None</pre></p><p><b>none</b><br><pre>None</pre></p><p><b>one</b><br><pre>None</pre></p><h1>raws.color</h1><p><b>black</b><br><pre>None</pre></p><p><b>blue</b><br><pre>None</pre></p><p><b>brown</b><br><pre>None</pre></p><p><b>color</b><br><pre>None</pre></p><p><b>cyan</b><br><pre>None</pre></p><p><b>dgray</b><br><pre>None</pre></p><p><b>green</b><br><pre>None</pre></p><p><b>lblue</b><br><pre>None</pre></p><p><b>lcyan</b><br><pre>None</pre></p><p><b>lgray</b><br><pre>None</pre></p><p><b>lgreen</b><br><pre>None</pre></p><p><b>lmagenta</b><br><pre>None</pre></p><p><b>lred</b><br><pre>None</pre></p><p><b>magenta</b><br><pre>None</pre></p><p><b>red</b><br><pre>None</pre></p><p><b>white</b><br><pre>None</pre></p><p><b>yellow</b><br><pre>None</pre></p><h1>raws.dir</h1><p><b>__contains__</b><br><pre>None</pre></p><p><b>__getitem__</b><br><pre>None</pre></p><p><b>__init__</b><br><pre>Constructor for rawsdir object.</pre></p><p><b>__iter__</b><br><pre>None</pre></p><p><b>__setitem__</b><br><pre>None</pre></p><p><b>addfile</b><br><pre>None</pre></p><p><b>addpath</b><br><pre>None</pre></p><p><b>all</b><br><pre>None</pre></p><p><b>allobj</b><br><pre>Gets all objects matching a given type and optional id or id regex.</pre></p><p><b>allprop</b><br><pre>Gets the all tokens matching the arguments, but stops at the next
token with the same value as this one. Should be sufficient in almost
all cases to get a token representing a property of an object, when
this method is called for a token representing an object. **kwargs are
passed to the alluntil method.
Example usage:
>>> hematite = df.getobj('INORGANIC:HEMATITE')
>>> print len(hematite.all('ENVIRONMENT')) # Gets all ENVIRONMENT tokens following hematite
38
>>> print hematite.allprop('ENVIRONMENT') # Gets only the ENVIRONMENT tokens belonging to hematite
[ENVIRONMENT:SEDIMENTARY:VEIN:100]
[ENVIRONMENT:IGNEOUS_EXTRUSIVE:VEIN:100]
</pre></p><p><b>alluntil</b><br><pre>None</pre></p><p><b>argsprops</b><br><pre>None</pre></p><p><b>argstokens</b><br><pre>None</pre></p><p><b>argsuntil</b><br><pre>None</pre></p><p><b>get</b><br><pre>None</pre></p><p><b>getfile</b><br><pre>Gets the file with a given name. If no file by that name is found,
None is returned instead. If creature is set to something other than
None, the behavior when no file by some name exists is altered: A new
file is created and associated with that name, and then its add
method is called using the value for create as its argument.</pre></p><p><b>getlast</b><br><pre>None</pre></p><p><b>getlastprop</b><br><pre>Gets the last token matching the arguments, but stops at the next
token with the same value as this one. Should be sufficient in almost
all cases to get a token representing a property of an object, when
this method is called for a token representing an object. **kwargs
are passed to the getlastuntil method.
Example usage:
>>> iron = df.getobj('INORGANIC:IRON')
>>> print iron.getlast(re_value='ITEMS_.+') # Gets the property of adamantite, the last ITEMS_ token in the file
[ITEMS_SOFT]
>>> print iron.getlastprop(re_value='ITEMS_.+') # Gets the last ITEMS_ token which belongs to iron
[ITEMS_SCALED]
</pre></p><p><b>getlastuntil</b><br><pre>None</pre></p><p><b>getobj</b><br><pre>Get the first object token matching a given type and id. (If there's more
than one result for any given query then I'm afraid you've done something
silly with your raws.) This method should work properly with things like
CREATURE:X tokens showing up in entity_default.</pre></p><p><b>getobjheadername</b><br><pre>None</pre></p><p><b>getobjheaders</b><br><pre>Gets OBJECT:X tokens where X is type. Is also prepared for special cases
like type=ITEM_PANTS matching OBJECT:ITEM. Current as of DF version 0.40.24.</pre></p><p><b>getprop</b><br><pre>Gets the first token matching the arguments, but stops at the next
token with the same value as this one. Should be sufficient in almost
all cases to get a token representing a property of an object, when
this method is called for a token representing an object. **kwargs
are passed to the getuntil method.
Example usage:
>>> iron = df.getobj('INORGANIC:IRON')
>>> print iron.get('WAFERS') # Gets the WAFERS token that's a property of adamantite
[WAFERS]
>>> print iron.getprop('WAFERS') # Stops at the next INORGANIC token, doesn't pick up adamantine's WAFERS token
None
</pre></p><p><b>getuntil</b><br><pre>None</pre></p><p><b>objdict</b><br><pre>None</pre></p><p><b>objpretty</b><br><pre>None</pre></p><p><b>propdict</b><br><pre>Returns a dictionary with token values mapped as keys to the tokens
themselves. If always_list is True then every item in the dict will be
a list. If it's False then items in the dict where only one token was
found will be given as individual rawstoken instances rather than as
lists. **kwargs are passed to the alluntil method.
Example usage:
>>> hematite = df.getobj('INORGANIC:HEMATITE')
>>> props = hematite.propdict()
>>> print props.get('ENVIRONMENT')
[
[ENVIRONMENT:SEDIMENTARY:VEIN:100],
[ENVIRONMENT:IGNEOUS_EXTRUSIVE:VEIN:100]]
>>> print props.get('IS_STONE')
[
[IS_STONE]]
>>> print props.get('TILE:156')
[[TILE:156]]
</pre></p><p><b>query</b><br><pre>None</pre></p><p><b>read</b><br><pre>Reads raws from all text files in the specified directory.</pre></p><p><b>removefile</b><br><pre>None</pre></p><p><b>setfile</b><br><pre>None</pre></p><p><b>tokens</b><br><pre>Iterate through all tokens.</pre></p><p><b>until</b><br><pre>None</pre></p><p><b>write</b><br><pre>Writes raws to the specified directory.</pre></p><h1>raws.file</h1><p><b>__contains__</b><br><pre>None</pre></p><p><b>__getitem__</b><br><pre>None</pre></p><p><b>__init__</b><br><pre>None</pre></p><p><b>__iter__</b><br><pre>None</pre></p><p><b>add</b><br><pre>None</pre></p><p><b>all</b><br><pre>None</pre></p><p><b>allprop</b><br><pre>Gets the all tokens matching the arguments, but stops at the next
token with the same value as this one. Should be sufficient in almost
all cases to get a token representing a property of an object, when
this method is called for a token representing an object. **kwargs are
passed to the alluntil method.
Example usage:
>>> hematite = df.getobj('INORGANIC:HEMATITE')
>>> print len(hematite.all('ENVIRONMENT')) # Gets all ENVIRONMENT tokens following hematite
38
>>> print hematite.allprop('ENVIRONMENT') # Gets only the ENVIRONMENT tokens belonging to hematite
[ENVIRONMENT:SEDIMENTARY:VEIN:100]
[ENVIRONMENT:IGNEOUS_EXTRUSIVE:VEIN:100]
</pre></p><p><b>alluntil</b><br><pre>None</pre></p><p><b>argsprops</b><br><pre>None</pre></p><p><b>argstokens</b><br><pre>None</pre></p><p><b>argsuntil</b><br><pre>None</pre></p><p><b>copy</b><br><pre>None</pre></p><p><b>get</b><br><pre>None</pre></p><p><b>getlast</b><br><pre>None</pre></p><p><b>getlastprop</b><br><pre>Gets the last token matching the arguments, but stops at the next
token with the same value as this one. Should be sufficient in almost
all cases to get a token representing a property of an object, when
this method is called for a token representing an object. **kwargs
are passed to the getlastuntil method.
Example usage:
>>> iron = df.getobj('INORGANIC:IRON')
>>> print iron.getlast(re_value='ITEMS_.+') # Gets the property of adamantite, the last ITEMS_ token in the file
[ITEMS_SOFT]
>>> print iron.getlastprop(re_value='ITEMS_.+') # Gets the last ITEMS_ token which belongs to iron
[ITEMS_SCALED]
</pre></p><p><b>getlastuntil</b><br><pre>None</pre></p><p><b>getprop</b><br><pre>Gets the first token matching the arguments, but stops at the next
token with the same value as this one. Should be sufficient in almost
all cases to get a token representing a property of an object, when
this method is called for a token representing an object. **kwargs
are passed to the getuntil method.
Example usage:
>>> iron = df.getobj('INORGANIC:IRON')
>>> print iron.get('WAFERS') # Gets the WAFERS token that's a property of adamantite
[WAFERS]
>>> print iron.getprop('WAFERS') # Stops at the next INORGANIC token, doesn't pick up adamantine's WAFERS token
None
</pre></p><p><b>getuntil</b><br><pre>None</pre></p><p><b>propdict</b><br><pre>Returns a dictionary with token values mapped as keys to the tokens
themselves. If always_list is True then every item in the dict will be
a list. If it's False then items in the dict where only one token was
found will be given as individual rawstoken instances rather than as
lists. **kwargs are passed to the alluntil method.
Example usage:
>>> hematite = df.getobj('INORGANIC:HEMATITE')
>>> props = hematite.propdict()
>>> print props.get('ENVIRONMENT')
[
[ENVIRONMENT:SEDIMENTARY:VEIN:100],
[ENVIRONMENT:IGNEOUS_EXTRUSIVE:VEIN:100]]
>>> print props.get('IS_STONE')
[
[IS_STONE]]
>>> print props.get('TILE:156')
[[TILE:156]]
</pre></p><p><b>query</b><br><pre>None</pre></p><p><b>read</b><br><pre>None</pre></p><p><b>remove</b><br><pre>None</pre></p><p><b>root</b><br><pre>Gets the first token in the file.</pre></p><p><b>settokens</b><br><pre>None</pre></p><p><b>tail</b><br><pre>Gets the last token in the file.</pre></p><p><b>tokens</b><br><pre>Iterate through all tokens.</pre></p><p><b>until</b><br><pre>None</pre></p><p><b>write</b><br><pre>None</pre></p><h1>raws.token</h1><p><b>__contains__</b><br><pre>None</pre></p><p><b>__eq__</b><br><pre>None</pre></p><p><b>__getitem__</b><br><pre>None</pre></p><p><b>__hash__</b><br><pre>None</pre></p><p><b>__init__</b><br><pre>None</pre></p><p><b>__iter__</b><br><pre>None</pre></p><p><b>__ne__</b><br><pre>None</pre></p><p><b>add</b><br><pre>None</pre></p><p><b>addall</b><br><pre>None</pre></p><p><b>addarg</b><br><pre>Appends an argument to the end of the argument list.
Example usage:
>>> token = raws.token('EXAMPLE')
>>> print token
[EXAMPLE]
>>> token.addarg('hi!')
>>> print token
[EXAMPLE:hi!]
</pre></p><p><b>addone</b><br><pre>None</pre></p><p><b>addprop</b><br><pre>When this token is an object token like CREATURE:X or INORGANIC:X, a
new token is usually added immediately afterwards. However, if a token like
COPY_TAGS_FROM or USE_MATERIAL_TEMPLATE exists underneath the object, then
the specified tag is only added after that. **kwargs are passed on to the
</pre></p><p><b>all</b><br><pre>None</pre></p><p><b>allprop</b><br><pre>Gets the all tokens matching the arguments, but stops at the next
token with the same value as this one. Should be sufficient in almost
all cases to get a token representing a property of an object, when
this method is called for a token representing an object. **kwargs are
passed to the alluntil method.
Example usage:
>>> hematite = df.getobj('INORGANIC:HEMATITE')
>>> print len(hematite.all('ENVIRONMENT')) # Gets all ENVIRONMENT tokens following hematite
38
>>> print hematite.allprop('ENVIRONMENT') # Gets only the ENVIRONMENT tokens belonging to hematite
[ENVIRONMENT:SEDIMENTARY:VEIN:100]
[ENVIRONMENT:IGNEOUS_EXTRUSIVE:VEIN:100]
</pre></p><p><b>alluntil</b><br><pre>None</pre></p><p><b>arg</b><br><pre>When a token is expected to have only one argument, this method can be used
to access it. It there's one argument it will be returned, otherwise an
exception will be raised.
Example usage:
>>> token_a = raws.token('EXAMPLE:x')
>>> token_b = raws.token('EXAMPLE:x:y:z')
>>> print token_a.arg()
x
>>> print token_b.arg()
>>> try:
... print token_b.arg()
... except:
... print 'token_b doesn't have the correct number of arguments!'
...
token_b doesn't have the correct number of arguments!</pre></p><p><b>argsprops</b><br><pre>None</pre></p><p><b>argsstr</b><br><pre>Return arguments joined by ':'.
Example usage:
>>> token = raws.token('EXAMPLE:a:b:c')
>>> print token.argsstr()
a:b:c
</pre></p><p><b>argstokens</b><br><pre>None</pre></p><p><b>argsuntil</b><br><pre>None</pre></p><p><b>auto</b><br><pre>None</pre></p><p><b>copy</b><br><pre>Copies some token or iterable collection of tokens.
Example usage:
>>> token = raws.token('EXAMPLE:a:b:c')
>>> print token
[EXAMPLE:a:b:c]
>>> copied_token = raws.token.copy(token)
>>> print copied_token
[EXAMPLE:a:b:c]
>>> print token is copied_token
False
>>> tokens = raws.token.parse('[HELLO][WORLD]')
>>> print tokens
[[HELLO], [WORLD]]
>>> copied_tokens = raws.token.copy(tokens)
>>> print copied_tokens
[[HELLO], [WORLD]]
>>> print tokens == copied_tokens
True
>>> print tokens is copied_tokens
False
</pre></p><p><b>equals</b><br><pre>Returns True if two tokens have identical values and arguments, False otherwise.
Example usage:
>>> token_a = raws.token('EXAMPLE:hi!')
>>> token_b = raws.token('EXAMPLE:hello there')
>>> token_c = raws.token('EXAMPLE:hi!')
>>> print token_a, token_b, token_c
[EXAMPLE:hi!] [EXAMPLE:hello there] [EXAMPLE:hi!]
>>> print token_a == token_b
False
>>> print token_b == token_c
False
>>> print token_c == token_a
True
>>> print token_c is token_a
False</pre></p><p><b>firstandlast</b><br><pre>Utility method for getting the first and last items of some iterable
</pre></p><p><b>propdict</b><br><pre>Returns a dictionary with token values mapped as keys to the tokens
themselves. If always_list is True then every item in the dict will be
a list. If it's False then items in the dict where only one token was
found will be given as individual rawstoken instances rather than as
lists. **kwargs are passed to the alluntil method.
Example usage:
>>> hematite = df.getobj('INORGANIC:HEMATITE')
>>> props = hematite.propdict()
>>> print props.get('ENVIRONMENT')
[
[ENVIRONMENT:SEDIMENTARY:VEIN:100],
[ENVIRONMENT:IGNEOUS_EXTRUSIVE:VEIN:100]]
>>> print props.get('IS_STONE')
[
[IS_STONE]]
>>> print props.get('TILE:156')
[[TILE:156]]
</pre></p><p><b>query</b><br><pre>None</pre></p><p><b>remove</b><br><pre>Removes this token and the next count tokens in the direction indicated by reverse.
</pre></p><p><b>tokensequal</b><br><pre>Determine whether two iterables containing tokens contain equivalent tokens.</pre></p><p><b>until</b><br><pre>None</pre></p><h1>raws.tokenfilter</h1><p><b>__init__</b><br><pre>Constructs an element of a query which either matches or doesn't match a given rawstoken.
Most arguments default to None. If some argument is None then that argument is not matched
on.
These arguments regard which tokens match and don't match the filter:
pretty: If specified, the string is parsed as a token and its value and arguments are used
as exact_value and exact_args.
match_token: If specified, its value and arguments are used as exact_value and exact_args.
exact_token: If a token is not this exact object, then it doesn't match.
exact_value: If a token does not have this exact value, then it doesn't match.
exact_args: If every one of a token's arguments do not exactly match these arguments, then
it doesn't match. None values within this tuple- or list-like object are treated as
wildcards. (These None arguments match everything.)
exact_arg: An iterable containing tuple- or list-like objects where the first element is
an index and the second element is a string. If for any index/string pair a token's
argument at the index does not exactly match the string, then the token doesn't match.
exact_prefix: If a token does not have this exact prefix - meaning the previous token's
suffix and its own prefix concatenated - then it doesn't match.
exact_suffix: If a token does not have this exact suffix - meaning its own suffix and the
next token's prefix concatenated - then it doesn't match.
re_value: If a token's value does not match this regular expression, then it doesn't match.
re_args: If every one of a token's arguments do not match these regular expressions, then
it doesn't match. None values within this tuple- or list-like object are treated as
wildcards. (These None arguments match everything.)
re_arg: An iterable containing tuple- or list-like objects where the first element is an
index and the second element is a regular expression string. If for any index/regex
pair a token's argument at the index does not match the regular expression, then the
token doesn't match.
re_prefix: If a token's prefix - meaning the previous token's suffix and its own prefix
concatenated - does not match this regular expression string then it doesn't match.
re_suffix: If a token's suffix - meaning its own suffix and the next token's prefix
concatenated - does not match this regular expression string then it doesn't match.
except_value: If a token has this exact value, then it doesn't match.
value_in: If a token's value is not contained within this iterable, then it doesn't match.
value_not_in: If a token's value is contained within this iterable, then it doesn't match.
arg_in: Handled like exact_arg or re_args, except checks for being contained by a list or
similar object rather than matching a single string or a regex.
args_contains: If at least one of a token's arguments is not exactly this string, then it
doesn't match.
args_count: If a token's number of arguments is not exactly this, then it doesn't match.
args_count_at_least: If a token's number of arguments is not at least this many then it
doesn't match.
args_count_no_more: If a token's number of arguments exceeds this many then it doesn't
match.
These arguments regard how the filter is treated in queries.
invert: Acts like 'not': Inverts what this filter does and doesn't match.
limit: After matching this many tokens, the filter will cease to accumulate results. If
limit is None, then the filter will never cease as long as the query continues.
limit_terminates: After matching the number of tokens indicated by limit, if this is set
to True then the query of which this filter is a member is made to terminated. If
set to False, then this filter will only cease to accumulate results. Defaults to