INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
encoding -- > str: one of ENCODINGS l -- > int: length of unicode str avoid -- > list of int: to void ( unprintable chars etc ) Returns -- > bytes representing unicode str of the requested encoding | def get_rand_bytes(encoding='latin1', l=64, avoid=[]):
'''
encoding-->str: one of ENCODINGS
l-->int: length of unicode str
avoid-->list of int: to void (unprintable chars etc)
Returns-->bytes representing unicode str of the requested encoding
'''
return encode(
get_rand_str(encoding=... |
Parse argv for options and arguments and start schema generation. | def main():
'''
Parse argv for options and arguments, and start schema generation.
'''
parser = optparse.OptionParser(usage="%prog [options] <model_path> [another_model_path...]",
formatter=optparse.TitledHelpFormatter())
parser.... |
Rip the events from a given rss feed normalize the data and store. | def scrape(ctx, url):
"""
Rip the events from a given rss feed, normalize the data and store.
"""
data = load_feed(url)
feed = data['feed']
entries = data['entries']
# THIS IS SPECIFIC TO # http://konfery.cz/rss/
_type = 'community'
country = 'Czech Republic'
# title, title_de... |
Download the image and return the local path to the image file. | def download_image(self):
"""
Download the image and return the
local path to the image file.
"""
split = urlsplit(self.url)
filename = split.path.split("/")[-1]
# Ensure the directory to store the image cache exists
if not os.path.exists(self.cache_direc... |
Method to check if an image has changed since it was last downloaded. By making a head request this check can be done quicker that downloading and processing the whole file. | def has_changed(self):
"""
Method to check if an image has changed
since it was last downloaded. By making
a head request, this check can be done
quicker that downloading and processing
the whole file.
"""
request = urllib_request.Request(self.url)
... |
Gets stolen bikes within a radius of a given postcode.: param request: The aiohttp request.: return: The bikes stolen with the given range from a postcode. | async def api_bikes(request):
"""
Gets stolen bikes within a radius of a given postcode.
:param request: The aiohttp request.
:return: The bikes stolen with the given range from a postcode.
"""
postcode: Optional[str] = request.match_info.get('postcode', None)
try:
radius = int(requ... |
Returns a template. Node subclass. | def fancy_tag_compiler(params, defaults, takes_var_args, takes_var_kwargs, takes_context, name, node_class, parser, token):
"Returns a template.Node subclass."
bits = token.split_contents()[1:]
if takes_context:
if 'context' in params[:1]:
params = params[1:]
else:
r... |
This will setup logging for a single file but can be called more than once LOG LEVELS are CRITICAL ERROR INFO DEBUG: param log_filename: str of the file location: param log_level: str of the overall logging level for setLevel: param str_format: str of the logging format: param date_format: str of the date format: param... | def setup_logging(log_filename=None, log_level="DEBUG", str_format=None,
date_format=None, log_file_level="DEBUG",
log_stdout_level=None, log_restart=False, log_history=False,
formatter=None, silence_modules=None, log_filter=None):
"""
This will setup loggin... |
This will setup logging for stdout and stderr: param formatter:: param log_level: str of the overall logging level for setLevel: param log_stdout_level: str of the logging level of stdout: param str_format: str of the logging format: param date_format: str of the date format: param silence_modules: list of str of modul... | def setup_stdout_logging(log_level="DEBUG", log_stdout_level="DEBUG",
str_format=None, date_format=None, formatter=None,
silence_modules=None, log_filter=None):
"""
This will setup logging for stdout and stderr
:param formatter:
:param log_level: ... |
This will setup logging for a single file but can be called more than once LOG LEVELS are CRITICAL ERROR INFO DEBUG: param log_filename: str of the file location: param log_file_level str of the log level to use on this file: param str_format: str of the logging format: param date_format: str of the date format: param ... | def setup_file_logging(log_filename, log_file_level="DEBUG", str_format=None,
date_format=None, log_restart=False, log_history=False,
formatter=None, silence_modules=None, log_filter=None):
"""
This will setup logging for a single file but can be called more than on... |
: param log_filename:: param log_file_level str of the log level to use on this file: param str_format: str of the logging format: param date_format: str of the date format: param log_restart: bool if True the log file will be deleted first: param log_history: bool if True will save another log file in a folder called ... | def add_file_handler(log_file_level, log_filename, str_format=None,
date_format=None, formatter=None, log_filter=None):
"""
:param log_filename:
:param log_file_level str of the log level to use on this file
:param str_format: str of the logging format
:param date_format:... |
: param log_handler_level: str of the level to set for the handler: param handler: logging. Handler handler to add: param formatter: logging. Formatter instance to use: param log_filter: logging. filter instance to add to handler: return: None | def add_handler(log_handler_level, handler, formatter=None, log_filter=None):
"""
:param log_handler_level: str of the level to set for the handler
:param handler: logging.Handler handler to add
:param formatter: logging.Formatter instance to use
:param log_filter: l... |
This will raise the log level for the given modules in general this is used to silence them: param modules: list of str of module names ex. [ requests ]: param log_level: str of the new log level: return: None | def set_module_log_level(modules=None, log_level=logging.WARNING):
"""
This will raise the log level for the given modules
in general this is used to silence them
:param modules: list of str of module names ex. ['requests']
:param log_level: str of the new log level
:return: ... |
Find the stack frame of the caller so that we can note the source file name line number and function name. | def findCaller(self, stack_info=False):
"""
Find the stack frame of the caller so that we can note the source
file name, line number and function name.
"""
f = logging.currentframe()
# On some versions of IronPython, currentframe() returns None if
# IronPython isn... |
get the C_C in which pe_pe is defined | def get_defining_component(pe_pe):
'''
get the C_C in which pe_pe is defined
'''
if pe_pe is None:
return None
if pe_pe.__class__.__name__ != 'PE_PE':
pe_pe = xtuml.navigate_one(pe_pe).PE_PE[8001]()
ep_pkg = xtuml.navigate_one(pe_pe).EP_PKG[8000]()
if ep_pkg:
... |
Transform textual OAL actions of an * instance * to instances in the ooaofooa subsystems Value and Body. The provided * instance * must be an instance of one of the following classes: - S_SYNC - S_BRG - O_TFR - O_DBATTR - SM_ACT - SPR_RO - SPR_RS - SPR_PO - SPR_PS | def prebuild_action(instance):
'''
Transform textual OAL actions of an *instance* to instances in the ooaofooa
subsystems Value and Body. The provided *instance* must be an instance of
one of the following classes:
- S_SYNC
- S_BRG
- O_TFR
- O_DBATTR
- SM_ACT
- SPR_RO
-... |
Transform textual OAL actions in a ooaofooa * metamodel * to instances in the subsystems Value and Body. Instances of the following classes are supported: - S_SYNC - S_BRG - O_TFR - O_DBATTR - SM_ACT - SPR_RO - SPR_RS - SPR_PO - SPR_PS | def prebuild_model(metamodel):
'''
Transform textual OAL actions in a ooaofooa *metamodel* to instances in the
subsystems Value and Body. Instances of the following classes are supported:
- S_SYNC
- S_BRG
- O_TFR
- O_DBATTR
- SM_ACT
- SPR_RO
- SPR_RS
- SPR_PO
- SPR_P... |
Parse command line options and launch the prebuilder. | def main():
'''
Parse command line options and launch the prebuilder.
'''
parser = optparse.OptionParser(usage="%prog [options] <model_path> [another_model_path..]",
version=xtuml.version.complete_string,
formatter=optparse.TitledHelp... |
Find a symbol in the symbol table by name kind or both. | def find_symbol(self, name=None, kind=None):
'''
Find a symbol in the symbol table by name, kind, or both.
'''
for s in reversed(self.stack):
for symbol_name, handle in s.symbols.items():
symbol_kind = handle.__class__.__name__
... |
input: gdata ContactEntry and GroupEntry objects | def update_membership(self, contact, group):
'''
input: gdata ContactEntry and GroupEntry objects
'''
if not contact:
log.debug('Not updating membership for EMPTY contact.')
return None
_uid = contact.email[0].address
_gtitle = group.title.text
... |
Determine if a PE_PE is contained within a EP_PKG or a C_C. | def is_contained_in(pe_pe, root):
'''
Determine if a PE_PE is contained within a EP_PKG or a C_C.
'''
if not pe_pe:
return False
if type(pe_pe).__name__ != 'PE_PE':
pe_pe = one(pe_pe).PE_PE[8001]()
ep_pkg = one(pe_pe).EP_PKG[8000]()
c_c = one(pe_pe).C_C[8003]()
... |
Check if a PE_PE is globally defined i. e. not inside a C_C | def is_global(pe_pe):
'''
Check if a PE_PE is globally defined, i.e. not inside a C_C
'''
if type(pe_pe).__name__ != 'PE_PE':
pe_pe = one(pe_pe).PE_PE[8001]()
if one(pe_pe).C_C[8003]():
return False
pe_pe = one(pe_pe).EP_PKG[8000].PE_PE[8001]()
if not pe_pe:
... |
Get the BridgePoint component ( C_C ) that defines the packeable element * pe_pe *. | def get_defining_component(pe_pe):
'''
Get the BridgePoint component (C_C) that defines the packeable element
*pe_pe*.
'''
if pe_pe is None:
return None
if type(pe_pe).__name__ != 'PE_PE':
pe_pe = one(pe_pe).PE_PE[8001]()
ep_pkg = one(pe_pe).EP_PKG[8000]()
if ep... |
Get the base data type ( S_DT ) associated with a BridgePoint attribute. | def get_attribute_type(o_attr):
'''
Get the base data type (S_DT) associated with a BridgePoint attribute.
'''
ref_o_attr = one(o_attr).O_RATTR[106].O_BATTR[113].O_ATTR[106]()
if ref_o_attr:
return get_attribute_type(ref_o_attr)
else:
return one(o_attr).S_DT[114]() |
Convert a BridgePoint data type to a pyxtuml meta model type. | def _get_data_type_name(s_dt):
'''
Convert a BridgePoint data type to a pyxtuml meta model type.
'''
s_cdt = one(s_dt).S_CDT[17]()
if s_cdt and s_cdt.Core_Typ in range(1, 6):
return s_dt.Name.upper()
if one(s_dt).S_EDT[17]():
return 'INTEGER'
s_dt = one(s_dt).S_UDT[... |
The two lists of attributes which relates two classes in an association. | def _get_related_attributes(r_rgo, r_rto):
'''
The two lists of attributes which relates two classes in an association.
'''
l1 = list()
l2 = list()
ref_filter = lambda ref: ref.OIR_ID == r_rgo.OIR_ID
for o_ref in many(r_rto).O_RTIDA[110].O_REF[111](ref_filter):
o_attr = one(o_re... |
Create a named tuple from a BridgePoint enumeration. | def mk_enum(s_edt):
'''
Create a named tuple from a BridgePoint enumeration.
'''
s_dt = one(s_edt).S_DT[17]()
enums = list()
kwlist =['False', 'None', 'True'] + keyword.kwlist
for enum in many(s_edt).S_ENUM[27]():
if enum.Name in kwlist:
enums.append(enum.Name + '_')
... |
Create a python function from a BridgePoint bridge. | def mk_bridge(metamodel, s_brg):
'''
Create a python function from a BridgePoint bridge.
'''
action = s_brg.Action_Semantics_internal
label = s_brg.Name
return lambda **kwargs: interpret.run_function(metamodel, label,
action, kwargs) |
Create a python object from a BridgePoint external entity with bridges realized as python member functions. | def mk_external_entity(metamodel, s_ee):
'''
Create a python object from a BridgePoint external entity with bridges
realized as python member functions.
'''
bridges = many(s_ee).S_BRG[19]()
names = [brg.Name for brg in bridges]
EE = collections.namedtuple(s_ee.Key_Lett, names)
funcs = l... |
Create a python function from a BridgePoint function. | def mk_function(metamodel, s_sync):
'''
Create a python function from a BridgePoint function.
'''
action = s_sync.Action_Semantics_internal
label = s_sync.Name
return lambda **kwargs: interpret.run_function(metamodel, label,
action, kwargs) |
Create a python value from a BridgePoint constant. | def mk_constant(cnst_syc):
'''
Create a python value from a BridgePoint constant.
'''
s_dt = one(cnst_syc).S_DT[1500]()
cnst_lsc = one(cnst_syc).CNST_LFSC[1502].CNST_LSC[1503]()
if s_dt.Name == 'boolean':
return cnst_lsc.Value.lower() == 'true'
if s_dt.Name == 'integer':
... |
Create a python function that interprets that action of a BridgePoint class operation. | def mk_operation(metaclass, o_tfr):
'''
Create a python function that interprets that action of a BridgePoint class
operation.
'''
o_obj = one(o_tfr).O_OBJ[115]()
action = o_tfr.Action_Semantics_internal
label = '%s::%s' % (o_obj.Name, o_tfr.Name)
run = interpret.run_operation
i... |
Create a python property that interprets that action of a BridgePoint derived attribute. | def mk_derived_attribute(metaclass, o_dbattr):
'''
Create a python property that interprets that action of a BridgePoint derived
attribute.
'''
o_attr = one(o_dbattr).O_BATTR[107].O_ATTR[106]()
o_obj = one(o_attr).O_OBJ[102]()
action = o_dbattr.Action_Semantics_internal
label = '%s::%s' ... |
Create a pyxtuml class from a BridgePoint class. | def mk_class(m, o_obj, derived_attributes=False):
'''
Create a pyxtuml class from a BridgePoint class.
'''
first_filter = lambda selected: not one(selected).O_ATTR[103, 'succeeds']()
o_attr = one(o_obj).O_ATTR[102](first_filter)
attributes = list()
while o_attr:
s_dt = get_a... |
Create a pyxtuml association from a simple association in BridgePoint. | def mk_simple_association(m, r_simp):
'''
Create a pyxtuml association from a simple association in BridgePoint.
'''
r_rel = one(r_simp).R_REL[206]()
r_form = one(r_simp).R_FORM[208]()
r_part = one(r_simp).R_PART[207]()
r_rgo = one(r_form).R_RGO[205]()
r_rto = one(r_part).R_RTO[204... |
Create pyxtuml associations from a linked association in BridgePoint. | def mk_linked_association(m, r_assoc):
'''
Create pyxtuml associations from a linked association in BridgePoint.
'''
r_rel = one(r_assoc).R_REL[206]()
r_rgo = one(r_assoc).R_ASSR[211].R_RGO[205]()
source_o_obj = one(r_rgo).R_OIR[203].O_OBJ[201]()
def _mk_assoc(side1, side2):
r_r... |
Create pyxtuml associations from a sub/ super association in BridgePoint. | def mk_subsuper_association(m, r_subsup):
'''
Create pyxtuml associations from a sub/super association in BridgePoint.
'''
r_rel = one(r_subsup).R_REL[206]()
r_rto = one(r_subsup).R_SUPER[212].R_RTO[204]()
target_o_obj = one(r_rto).R_OIR[203].O_OBJ[201]()
for r_sub in many(r_subsup).R_S... |
Create a pyxtuml association from a R_REL in ooaofooa. | def mk_association(m, r_rel):
'''
Create a pyxtuml association from a R_REL in ooaofooa.
'''
handler = {
'R_SIMP': mk_simple_association,
'R_ASSOC': mk_linked_association,
'R_SUBSUP': mk_subsuper_association,
'R_COMP': mk_derived_association,
}
inst = subtype(r_re... |
Create a pyxtuml meta model from a BridgePoint model. Optionally restrict to classes and associations contained in the component c_c. | def mk_component(bp_model, c_c=None, derived_attributes=False):
'''
Create a pyxtuml meta model from a BridgePoint model.
Optionally, restrict to classes and associations contained in the
component c_c.
'''
target = Domain()
c_c_filt = lambda sel: c_c is None or is_contained_in(sel, c_c)
... |
Load and return a metamodel expressed in ooaofooa from a * resource *. The resource may be either a filename a path or a list of filenames and/ or paths. | def load_metamodel(resource=None, load_globals=True):
'''
Load and return a metamodel expressed in ooaofooa from a *resource*.
The resource may be either a filename, a path, or a list of filenames
and/or paths.
'''
loader = _mk_loader(resource, load_globals)
return loader.build_metamodel() |
Load and return a model from a * resource *. The resource may be either a filename a path or a list of filenames and/ or paths. | def load_component(resource, name=None, load_globals=True):
'''
Load and return a model from a *resource*. The resource may be either a
filename, a path, or a list of filenames and/or paths.
'''
loader = _mk_loader(resource, load_globals)
return loader.build_component() |
Remove global instances e. g. the core data type integer. | def delete_globals(m, disconnect=False):
'''
Remove global instances, e.g. the core data type integer.
'''
filt = lambda sel: (247728914420827907967735776184937480192 <=
sel.DT_ID <=
247728914420827907967735776184937480208)
for s_dt in m.select_many... |
Open and read input from a * path or filename * and parse its content. If the filename is a directory files that ends with. xtuml located somewhere in the directory or sub directories will be loaded as well. | def filename_input(self, path_or_filename):
'''
Open and read input from a *path or filename*, and parse its content.
If the filename is a directory, files that ends with .xtuml located
somewhere in the directory or sub directories will be loaded as well.
'''
if ... |
Instantiate and build a component from ooaofooa named * name * as a pyxtuml model. Classes associations attributes and unique identifers i. e. O_OBJ R_REL O_ATTR in ooaofooa are defined in the resulting pyxtuml model. Optionally control whether * derived attributes * shall be mapped into the resulting pyxtuml model as ... | def build_component(self, name=None, derived_attributes=False):
'''
Instantiate and build a component from ooaofooa named *name* as a
pyxtuml model. Classes, associations, attributes and unique identifers,
i.e. O_OBJ, R_REL, O_ATTR in ooaofooa, are defined in the resulting
pyxtum... |
The default malformed message handler for: class: Worker. It warns as a: exc: MalformedMessage. | def default_malformed_message_handler(worker, exc_info, message_parts):
"""The default malformed message handler for :class:`Worker`. It warns
as a :exc:`MalformedMessage`.
"""
exc_type, exc, tb = exc_info
exc_strs = traceback.format_exception_only(exc_type, exc)
exc_str = exc_strs[0].strip()
... |
Calls a function and send results to the collector. It supports all of function actions. A function could return yield raise any packable objects. | def work(self, socket, call, args, kwargs, topics=()):
"""Calls a function and send results to the collector. It supports
all of function actions. A function could return, yield, raise any
packable objects.
"""
task_id = uuid4_bytes()
reply_socket, topics = self.replier... |
Sends ACCEPT reply. | def accept(self, reply_socket, channel):
"""Sends ACCEPT reply."""
info = self.info or b''
self.send_raw(reply_socket, ACCEPT, info, *channel) |
Sends REJECT reply. | def reject(self, reply_socket, call_id, topics=()):
"""Sends REJECT reply."""
info = self.info or b''
self.send_raw(reply_socket, REJECT, info, call_id, b'', topics) |
Sends RAISE reply. | def raise_(self, reply_socket, channel, exc_info=None):
"""Sends RAISE reply."""
if not reply_socket:
return
if exc_info is None:
exc_info = sys.exc_info()
exc_type, exc, tb = exc_info
while tb.tb_next is not None:
tb = tb.tb_next
if is... |
Allocates a call id and emit. | def _call_wait(self, hints, name, args, kwargs, topics=(), raw=False,
limit=None, retry=False, max_retries=None):
"""Allocates a call id and emit."""
col = self.collector
if not col.is_running():
col.start()
call_id = uuid4_bytes()
reply_to = (DUPLE... |
Waits for the call is accepted by workers and starts to collect the results. | def establish(self, call_id, timeout, limit=None,
retry=None, max_retries=None):
"""Waits for the call is accepted by workers and starts to collect the
results.
"""
rejected = 0
retried = 0
results = []
result_queue = self.result_queues[call_id]
... |
Dispatches the reply to the proper queue. | def dispatch_reply(self, reply, value):
"""Dispatches the reply to the proper queue."""
method = reply.method
call_id = reply.call_id
task_id = reply.task_id
if method & ACK:
try:
result_queue = self.result_queues[call_id]
except KeyError:
... |
Guess the type name of a serialized value. | def guess_type_name(value):
'''
Guess the type name of a serialized value.
'''
value = str(value)
if value.upper() in ['TRUE', 'FALSE']:
return 'BOOLEAN'
elif re.match(r'(-)?(\d+)(\.\d+)', value):
return 'REAL'
elif re.match(r'(-)?(\d+)', value):
return... |
Deserialize a value of some type | def deserialize_value(ty, value):
'''
Deserialize a value of some type
'''
uty = ty.upper()
if uty == 'BOOLEAN':
if value.isdigit():
return bool(int(value))
elif value.upper() == 'FALSE':
return False
elif value.upper() == 'TRUE':
retu... |
Load and return a metamodel from a * resource *. The * resource * may be either a filename or a list of filenames. Usage example: >>> metamodel = xtuml. load_metamodel ( [ schema. sql data. sql ] ) | def load_metamodel(resource):
'''
Load and return a metamodel from a *resource*. The *resource* may be either
a filename, or a list of filenames.
Usage example:
>>> metamodel = xtuml.load_metamodel(['schema.sql', 'data.sql'])
'''
if isinstance(resource, str):
resource = [re... |
Parse * data * directly from a string. The * name * is used when reporting positional information if the parser encounter syntax errors. | def input(self, data, name='<string>'):
'''
Parse *data* directly from a string. The *name* is used when reporting
positional information if the parser encounter syntax errors.
'''
lexer = lex.lex(debuglog=logger,
errorlog=logger,
o... |
Read and parse data from a * file object * i. e. the type of object returned by the builtin python function * open () *. | def file_input(self, file_object):
'''
Read and parse data from a *file object*, i.e. the type of object
returned by the builtin python function *open()*.
'''
return self.input(file_object.read(), name=file_object.name) |
Populate a * metamodel * with classes previously encountered from input. | def populate_classes(self, metamodel):
'''
Populate a *metamodel* with classes previously encountered from input.
'''
for stmt in self.statements:
if isinstance(stmt, CreateClassStmt):
metamodel.define_class(stmt.kind, stmt.attributes) |
Populate a * metamodel * with associations previously encountered from input. | def populate_associations(self, metamodel):
'''
Populate a *metamodel* with associations previously encountered from
input.
'''
for stmt in self.statements:
if not isinstance(stmt, CreateAssociationStmt):
continue
ass = metamod... |
Populate a * metamodel * with class unique identifiers previously encountered from input. | def populate_unique_identifiers(self, metamodel):
'''
Populate a *metamodel* with class unique identifiers previously
encountered from input.
'''
for stmt in self.statements:
if isinstance(stmt, CreateUniqueStmt):
metamodel.define_unique_identifier(stm... |
Populate a * metamodel * with a class that matches the given * insert statement *. | def _populate_matching_class(metamodel, kind, names, values):
'''
Populate a *metamodel* with a class that matches the given *insert
statement*.
'''
attributes = list()
for name, value in zip(names, values):
ty = guess_type_name(value)
attr = (name... |
Populate a * metamodel * with an instance previously encountered from input that was defined using positional arguments. | def _populate_instance_with_positional_arguments(metamodel, stmt):
'''
Populate a *metamodel* with an instance previously encountered from
input that was defined using positional arguments.
'''
if stmt.kind.upper() not in metamodel.metaclasses:
names = ['_%s' % idx f... |
Populate a * metamodel * with an instance previously encountered from input that was defined using named arguments. | def _populate_instance_with_named_arguments(metamodel, stmt):
'''
Populate a *metamodel* with an instance previously encountered from
input that was defined using named arguments.
'''
if stmt.kind.upper() not in metamodel.metaclasses:
ModelLoader._populate_matching_c... |
Populate a * metamodel * with instances previously encountered from input. | def populate_instances(self, metamodel):
'''
Populate a *metamodel* with instances previously encountered from
input.
'''
for stmt in self.statements:
if not isinstance(stmt, CreateInstanceStmt):
continue
if stmt.names:
... |
Populate links in a * metamodel * with connections between them. | def populate_connections(self, metamodel):
'''
Populate links in a *metamodel* with connections between them.
'''
storage = dict()
for ass in metamodel.associations:
source_class = ass.source_link.to_metaclass
target_class = ass.target_link.to_metaclass
... |
Populate a * metamodel * with entities previously encountered from input. | def populate(self, metamodel):
'''
Populate a *metamodel* with entities previously encountered from input.
'''
self.populate_classes(metamodel)
self.populate_unique_identifiers(metamodel)
self.populate_associations(metamodel)
self.populate_instances(metamodel)
... |
Build and return a * xtuml. MetaModel * containing previously loaded input. | def build_metamodel(self, id_generator=None):
'''
Build and return a *xtuml.MetaModel* containing previously loaded input.
'''
m = xtuml.MetaModel(id_generator)
self.populate(m)
return m |
r | def t_COMMA(self, t):
r','
t.endlexpos = t.lexpos + len(t.value)
return t |
r ( \ d + ) ( \. \ d + ) | def t_FRACTION(self, t):
r'(\d+)(\.\d+)'
t.endlexpos = t.lexpos + len(t.value)
return t |
r R [ 0 - 9 ] + | def t_RELID(self, t):
r'R[0-9]+'
t.endlexpos = t.lexpos + len(t.value)
return t |
r ( 1C ) | def t_CARDINALITY(self, t):
r'(1C)'
t.endlexpos = t.lexpos + len(t.value)
return t |
r [ A - Za - z_ ] [ \ w_ ] * | def t_ID(self, t):
r'[A-Za-z_][\w_]*'
vup = t.value.upper()
if vup in self.reserved:
t.type = vup
t.endlexpos = t.lexpos + len(t.value)
return t |
r \ ( | def t_LPAREN(self, t):
r'\('
t.endlexpos = t.lexpos + len(t.value)
return t |
r - | def t_MINUS(self, t):
r'-'
t.endlexpos = t.lexpos + len(t.value)
return t |
r [ 0 - 9 ] + | def t_NUMBER(self, t):
r'[0-9]+'
t.endlexpos = t.lexpos + len(t.value)
return t |
r \ ) | def t_RPAREN(self, t):
r'\)'
t.endlexpos = t.lexpos + len(t.value)
return t |
r ; | def t_SEMICOLON(self, t):
r';'
t.endlexpos = t.lexpos + len(t.value)
return t |
r \ ( [ ^ \\\ n ] | ( \\. )) * ? \ | def t_GUID(self, t):
r'\"([^\\\n]|(\\.))*?\"'
t.endlexpos = t.lexpos + len(t.value)
return t |
r \ n + | def t_newline(self, t):
r'\n+'
t.lexer.lineno += len(t.value)
t.endlexpos = t.lexpos + len(t.value) |
statement: create_table_statement SEMICOLON | insert_into_statement SEMICOLON | create_rop_statement SEMICOLON | create_index_statement SEMICOLON | def p_statement(self, p):
'''
statement : create_table_statement SEMICOLON
| insert_into_statement SEMICOLON
| create_rop_statement SEMICOLON
| create_index_statement SEMICOLON
'''
p[0] = p[1]
p[0].offset = p.lexpos(1)
... |
create_rop_statement: CREATE ROP REF_ID RELID FROM association_end TO association_end | def p_create_rop_statement(self, p):
'''create_rop_statement : CREATE ROP REF_ID RELID FROM association_end TO association_end'''
args = [p[4]]
args.extend(p[6])
args.extend(p[8])
p[0] = CreateAssociationStmt(*args) |
cardinality: NUMBER | def p_cardinality_1(self, p):
'''cardinality : NUMBER'''
if p[1] != '1':
raise ParsingException("illegal cardinality (%s) at %s:%d" % (p[1],
p.lexer.filename, p.lineno(1)))
p[0] = p[1] |
cardinality: ID | def p_cardinality_many(self, p):
'''cardinality : ID'''
if p[1] not in ['M', 'MC']:
raise ParsingException("illegal cardinality (%s) at %s:%d" % (p[1],
p.lexer.filename, p.lineno(1)))
p[0] = p[1] |
Read key - value pair files with secrets. For example. conf and. ini files.: return: | def append_known_secrets(self): # type: () -> None
"""
Read key-value pair files with secrets. For example, .conf and .ini files.
:return:
"""
for file_name in self.files:
if "~" in file_name:
file_name = os.path.expanduser(file_name)
if n... |
Search a path for known secrets outputing text and file when found: return: | def search_known_secrets(self): # type: () -> None
"""
Search a path for known secrets, outputing text and file when found
:return:
"""
count = 0
here = os.path.abspath(self.source)
# python 3 only!
# for file in glob.glob(here + "/" + "**/*.*", recursive... |
Encode id ( bytes ) as a Unicode string. | def eid(s):
'''Encode id (bytes) as a Unicode string.
The encoding is done such that lexicographic order is
preserved. No concern is given to wasting space.
The inverse of ``eid`` is ``did``.
'''
if isinstance(s, unicode):
s = s.encode('utf-8')
return u''.join('{:02x}'.format(ord(b... |
Decode id ( Unicode string ) as a bytes. | def did(s):
'''Decode id (Unicode string) as a bytes.
The inverse of ``did`` is ``eid``.
'''
return ''.join(chr(int(s[i:i+2], base=16)) for i in xrange(0, len(s), 2)) |
Retrieve a feature collection. | def get(self, content_id, feature_names=None):
'''Retrieve a feature collection.
If a feature collection with the given id does not
exist, then ``None`` is returned.
:param str content_id: Content identifier.
:param [str] feature_names:
A list of feature names to retr... |
Returns an iterable of feature collections. | def get_many(self, content_ids, feature_names=None):
'''Returns an iterable of feature collections.
This efficiently retrieves multiple FCs corresponding to the
list of ids given. Tuples of identifier and feature collection
are yielded. If the feature collection for a given id does not
... |
Adds feature collections to the store. | def put(self, items, indexes=True):
'''Adds feature collections to the store.
This efficiently adds multiple FCs to the store. The iterable
of ``items`` given should yield tuples of ``(content_id, FC)``.
:param items: Iterable of ``(content_id, FC)``.
:param [str] feature_names... |
Deletes the corresponding feature collection. | def delete(self, content_id):
'''Deletes the corresponding feature collection.
If the FC does not exist, then this is a no-op.
'''
try:
self.conn.delete(index=self.index, doc_type=self.type,
id=eid(content_id))
except NotFoundError:
... |
Deletes all feature collections. | def delete_all(self):
'''Deletes all feature collections.
This does not destroy the ES index, but instead only
deletes all FCs with the configured document type
(defaults to ``fc``).
'''
try:
self.conn.indices.delete_mapping(
index=self.index,... |
Deletes the underlying ES index. | def delete_index(self):
'''Deletes the underlying ES index.
Only use this if you know what you're doing. This destroys
the entire underlying ES index, which could be shared by
multiple distinct ElasticStore instances.
'''
if self.conn.indices.exists(index=self.index):
... |
Scan for FCs in the given id ranges. | def scan(self, *key_ranges, **kwargs):
'''Scan for FCs in the given id ranges.
:param key_ranges:
``key_ranges`` should be a list of pairs of ranges. The first
value is the lower bound id and the second value is the
upper bound id. Use ``()`` in either position to leave it... |
Scan for ids only in the given id ranges. | def scan_ids(self, *key_ranges, **kwargs):
'''Scan for ids only in the given id ranges.
:param key_ranges:
``key_ranges`` should be a list of pairs of ranges. The first
value is the lower bound id and the second value is the
upper bound id. Use ``()`` in either position to... |
Scan for FCs with a given prefix. | def scan_prefix(self, prefix, feature_names=None):
'''Scan for FCs with a given prefix.
:param str prefix: Identifier prefix.
:param [str] feature_names:
A list of feature names to retrieve. When ``None``, all
features are retrieved. Wildcards are allowed.
:rtype: It... |
Scan for ids with a given prefix. | def scan_prefix_ids(self, prefix):
'''Scan for ids with a given prefix.
:param str prefix: Identifier prefix.
:param [str] feature_names:
A list of feature names to retrieve. When ``None``, all
features are retrieved. Wildcards are allowed.
:rtype: Iterable of ``cont... |
Fulltext search. | def fulltext_scan(self, query_id=None, query_fc=None, feature_names=None,
preserve_order=True, indexes=None):
'''Fulltext search.
Yields an iterable of triples (score, identifier, FC)
corresponding to the search results of the fulltext search
in ``query``. This wil... |
Fulltext search for identifiers. | def fulltext_scan_ids(self, query_id=None, query_fc=None,
preserve_order=True, indexes=None):
'''Fulltext search for identifiers.
Yields an iterable of triples (score, identifier)
corresponding to the search results of the fulltext search
in ``query``. This wil... |
Keyword scan for feature collections. | def keyword_scan(self, query_id=None, query_fc=None, feature_names=None):
'''Keyword scan for feature collections.
This performs a keyword scan using the query given. A keyword
scan searches for FCs with terms in each of the query's indexed
fields.
At least one of ``query_id`` ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.