_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q53900 | validate_overwrite_different_input_output | train | def validate_overwrite_different_input_output(opts):
"""
Make sure that if overwrite is set to False, the input and output folders
are not set to the same location.
:param opts: a namespace containing the attributes 'overwrite', 'input',
and 'output'
:raises ValidationException: if 'input' ... | python | {
"resource": ""
} |
q53901 | app_update_state | train | def app_update_state(app_id,state):
"""
update app state
"""
try:
create_at = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
conn = get_conn()
c = conn.cursor()
c.execute("UPDATE app SET state='{0}',change_at='{1}' WHERE id='{2}'".format(state, create_at, app_id))
... | python | {
"resource": ""
} |
q53902 | create_app | train | def create_app(app_id, app_name, source_id, region, app_data):
"""
insert app record when stack run as a app
"""
try:
create_at = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
conn = get_conn()
c = conn.cursor()
#check old app
c.execute("SELECT count(*) F... | python | {
"resource": ""
} |
q53903 | delete_app_info | train | def delete_app_info(app_id):
"""
delete app info from local db
"""
try:
conn = get_conn()
c = conn.cursor()
c.execute("DELETE FROM container WHERE app_id='{0}'".format(app_id))
c.execute("DELETE FROM app WHERE id='{0}'".format(app_id))
conn.commit()
#print... | python | {
"resource": ""
} |
q53904 | stop_app | train | def stop_app(app_id, is_finished=False):
"""
update app state to 'Stopped'
"""
state = constant.STATE_APP_STOPPED if is_finished else constant.STATE_APP_STOPPING
app_update_state(app_id, state) | python | {
"resource": ""
} |
q53905 | terminate_app | train | def terminate_app(app_id, is_finished=False):
"""
update app state to 'Terminated'
"""
state = constant.STATE_APP_TERMINATED if is_finished else constant.STATE_APP_TERMINATING
app_update_state(app_id, state)
if is_finished:
delete_app_info(app_id) | python | {
"resource": ""
} |
q53906 | get_app_list | train | def get_app_list(region_name=None,filter_name=None):
"""
get local app list
"""
try:
conn = get_conn()
c = conn.cursor()
cond = []
where_clause = ""
if region_name:
cond.append( "region='{0}' ".format(region_name) )
if filter_name:
... | python | {
"resource": ""
} |
q53907 | create_container | train | def create_container(app_id,container_id,container_name):
"""
insert container record when create container
"""
try:
conn = get_conn()
c = conn.cursor()
c.execute("INSERT INTO container (id,name,app_id) VALUES ('{0}','{1}','{2}')"
.format(container_id,container_name,a... | python | {
"resource": ""
} |
q53908 | get_app_state | train | def get_app_state(app_id):
"""
get app state
"""
try:
conn = get_conn()
c = conn.cursor()
c.execute("SELECT state FROM app WHERE id='{0}' ".format(app_id))
result = c.fetchone()
conn.close()
if result:
state = result[0]
return stat... | python | {
"resource": ""
} |
q53909 | PlayerRecord.attrs | train | def attrs(self):
"""provide a copy of this player's attributes as a dictionary"""
ret = dict(self.__dict__) # obtain copy of internal __dict__
del ret["_matches"] # match history is specifically distinguished from player information (and stored separately)
if self.type != c.COMPUTER: # d... | python | {
"resource": ""
} |
q53910 | PlayerRecord.simpleAttrs | train | def simpleAttrs(self):
"""provide a copy of this player's attributes as a dictionary, but with objects flattened into a string representation of the object"""
simpleAttrs = {}
for k,v in iteritems(self.attrs):
if k in ["_matches"]: continue # attributes to specifically ignore
... | python | {
"resource": ""
} |
q53911 | PlayerRecord.control | train | def control(self):
"""the type of control this player exhibits"""
if self.isComputer: value = c.COMPUTER
else: value = c.PARTICIPANT
return c.PlayerControls(value) | python | {
"resource": ""
} |
q53912 | PlayerRecord.load | train | def load(self, playerName=None):
"""retrieve the PlayerRecord settings from saved disk file"""
if playerName: # switch the PlayerRecord this object describes
self.name = playerName # preset value to load self.filename
try:
with open(self.filename, "rb") as f:
... | python | {
"resource": ""
} |
q53913 | PlayerRecord.save | train | def save(self):
"""save PlayerRecord settings to disk"""
data = str.encode( json.dumps(self.simpleAttrs, indent=4, sort_keys=True) )
with open(self.filename, "wb") as f:
f.write(data) | python | {
"resource": ""
} |
q53914 | PlayerRecord.matchSubset | train | def matchSubset(**kwargs):
"""extract matches from player's entire match history given matching criteria kwargs"""
ret = []
for m in self.matches:
allMatched = True
for k,v in iteritems(kwargs):
mVal = getattr(m, k)
try:
... | python | {
"resource": ""
} |
q53915 | PlayerRecord.apmRecent | train | def apmRecent(self, maxMatches=c.RECENT_MATCHES, **criteria):
"""collect recent match history's apm data to report player's calculated MMR"""
if not self.matches: return 0 # no apm information without match history
#try: maxMatches = criteria["maxMatches"]
#except: maxMatches ... | python | {
"resource": ""
} |
q53916 | PlayerRecord.apmAggregate | train | def apmAggregate(self, **criteria):
"""collect all match history's apm data to report player's calculated MMR"""
apms = [m.apm(self) for m in self.matchSubset(**criteria)]
if not apms: return 0 # no apm information without match history
return sum(apms) / len(apms) | python | {
"resource": ""
} |
q53917 | PlayerRecord.recentMatches | train | def recentMatches(self, **criteria):
"""identify all recent matches for player given optional, additional criteria"""
if not self.matches: return [] # no match history
try: # maxMatches is a specially handled parameter (not true criteria)
maxMatches = criteria["maxMatches"]
... | python | {
"resource": ""
} |
q53918 | drafts | train | def drafts(files, stack):
"Filter out any files marked 'draft'"
for path, post in list(files.items()):
if post.get('draft'):
del files[path] | python | {
"resource": ""
} |
q53919 | unpack_archive | train | def unpack_archive(*components, **kwargs) -> str:
"""
Unpack a compressed archive.
Arguments:
*components (str[]): Absolute path.
**kwargs (dict, optional): Set "compression" to compression type.
Default: bz2. Set "dir" to destination directory. Defaults to the
direc... | python | {
"resource": ""
} |
q53920 | xlsx_to_strio | train | def xlsx_to_strio(xlsx_wb):
"""
convert xlwt Workbook instance to a BytesIO instance
"""
_xlrd_required()
fh = BytesIO()
xlsx_wb.filename = fh
xlsx_wb.close()
# prep for reading
fh.seek(0)
return fh | python | {
"resource": ""
} |
q53921 | Writer.get_font | train | def get_font(self, values):
"""
'height' 10pt = 200, 8pt = 160
"""
font_key = values
f = self.FONT_FACTORY.get(font_key, None)
if f is None:
f = xlwt.Font()
for attr, value in values:
f.__setattr__(attr, value)
self.FONT... | python | {
"resource": ""
} |
q53922 | DaemonRunnerWrapper.run_daemon | train | def run_daemon(self):
"""
Used as daemon starter.
Warning:
DO NOT OVERRIDE THIS.
"""
try:
self.daemon_runner.do_action()
except daemon.runner.DaemonRunnerStopFailureError:
self.onStopFail()
except SystemExit:
self.o... | python | {
"resource": ""
} |
q53923 | wrapAtom | train | def wrapAtom(xml, id, title, author=None, updated=None, author_uri=None,
alt=None, alt_type="text/html"):
"""
Create an Atom entry tag and embed the passed XML within it
"""
entryTag = etree.Element(ATOM + "entry", nsmap=ATOM_NSMAP)
titleTag = etree.SubElement(entryTag, ATOM + "title")... | python | {
"resource": ""
} |
q53924 | getOxum | train | def getOxum(dataPath):
"""
Calculate the oxum for a given path
"""
fileCount = 0L
fileSizeTotal = 0L
for root, dirs, files in os.walk(dataPath):
for fileName in files:
fullName = os.path.join(root, fileName)
stats = os.stat(fullName)
fileSizeTotal += ... | python | {
"resource": ""
} |
q53925 | getBagTags | train | def getBagTags(bagInfoPath):
"""
get bag tags
"""
try:
bagInfoString = open(bagInfoPath, "r").read().decode('utf-8')
except UnicodeDecodeError:
bagInfoString = open(bagInfoPath, "r").read().decode('iso-8859-1')
bagTags = anvl.readANVLString(bagInfoString)
return bagTags | python | {
"resource": ""
} |
q53926 | bagToXML | train | def bagToXML(bagPath, ark_naan=None):
"""
Given a path to a bag, read stuff about it and make an XML file
"""
# This is so .DEFAULT_ARK_NAAN can be modified
# at runtime.
if ark_naan is None:
ark_naan = DEFAULT_ARK_NAAN
bagInfoPath = os.path.join(bagPath, "bag-info.txt")
bagTags ... | python | {
"resource": ""
} |
q53927 | getValueByName | train | def getValueByName(node, name):
"""
A helper function to pull the values out of those annoying namespace
prefixed tags
"""
try:
value = node.xpath("*[local-name() = '%s']" % name)[0].text.strip()
except:
return None
return value | python | {
"resource": ""
} |
q53928 | getNodeByName | train | def getNodeByName(node, name):
"""
Get the first child node matching a given local name
"""
if node is None:
raise Exception(
"Cannot search for a child '%s' in a None object" % (name,)
)
if not name:
raise Exception("Unspecified name to find node for.")
try:... | python | {
"resource": ""
} |
q53929 | nodeToXML | train | def nodeToXML(nodeObject):
"""
Take a Django node object from our CODA store and make an XML
representation
"""
xmlRoot = etree.Element(NODE + "node", nsmap=NODE_NSMAP)
nameNode = etree.SubElement(xmlRoot, NODE + "name")
nameNode.text = nodeObject.node_name
urlNode = etree.SubElement(xm... | python | {
"resource": ""
} |
q53930 | queueEntryToXML | train | def queueEntryToXML(queueEntry):
"""
Turn an instance of a QueueEntry model into an xml data format
"""
xmlRoot = etree.Element(QXML + "queueEntry", nsmap=QXML_NSMAP)
arkTag = etree.SubElement(xmlRoot, QXML + "ark")
arkTag.text = queueEntry.ark
oxumTag = etree.SubElement(xmlRoot, QXML + "ox... | python | {
"resource": ""
} |
q53931 | makeServiceDocXML | train | def makeServiceDocXML(title, collections):
"""
Make an ATOM service doc here. The 'collections' parameter is a list of
dictionaries, with the keys of 'title', 'accept' and 'categories'
being valid
"""
serviceTag = etree.Element("service")
workspaceTag = etree.SubElement(serviceTag, "workspa... | python | {
"resource": ""
} |
q53932 | addObjectFromXML | train | def addObjectFromXML(xmlObject, XMLToObjectFunc,
topLevelName, idKey, updateList):
"""
Handle adding or updating the Queue. Based on XML input.
"""
# Get the current object to update
contentElement = getNodeByName(xmlObject, "content")
objectNode = getNodeByName(contentEle... | python | {
"resource": ""
} |
q53933 | updateObjectFromXML | train | def updateObjectFromXML(xml_doc, obj, mapping):
"""
Handle updating an object. Based on XML input.
"""
nsmap = None
if isinstance(mapping, dict):
# The special key @namespaces is used to pass
# namespaces and prefix mappings for xpath selectors.
# e.g. {'x': 'http://example.... | python | {
"resource": ""
} |
q53934 | plt2xyz | train | def plt2xyz(fname):
"""Convert a Compass plot file to XYZ pointcloud"""
parser = CompassPltParser(fname)
plt = parser.parse()
for segment in plt:
for command in segment:
if command.cmd == 'd':
if plt.utm_zone:
x, y, z = command.x * FT_TO_M, command.y * FT_TO_M, command.z * FT_TO_M
else:
x, y... | python | {
"resource": ""
} |
q53935 | Router.load_routes | train | def load_routes(self):
"""
Load all routes in project's folder 'controllers'.
Ignore files with leading underscore (for example: controllers/_blog.py)
"""
for file_name in os.listdir(os.path.join(self._project_dir, 'controllers')):
# ignore disabled controllers
... | python | {
"resource": ""
} |
q53936 | Router.get_controller | train | def get_controller(self, path):
"""
Return controller that handle given path.
Args:
- path: requested path, like: /blog/post_view/15
"""
path_info = path.lstrip('/').split('/', 2)
try:
return self._routes.get(path_info[0] + '/' + path_info[1])
... | python | {
"resource": ""
} |
q53937 | PanasonicBD.send_key | train | def send_key(self, key):
""" Send the supplied keypress to the device """
# Sanity check it's a valid key
if key not in KEYS:
return ['error', None]
url = 'http://%s/WAN/%s/%s_ctrl.cgi' % (self._host, 'dvdr', 'dvdr')
data = ('cCMD_RC_%s.x=100&cCMD_RC_%s.y=100' % (key... | python | {
"resource": ""
} |
q53938 | Search_QLineEdit.__set_clear_button_visibility | train | def __set_clear_button_visibility(self, text):
"""
Sets the clear button visibility.
:param text: Current field text.
:type text: QString
"""
if text:
self.__clear_button.show()
else:
self.__clear_button.hide() | python | {
"resource": ""
} |
q53939 | read_file | train | def read_file(*components, **kwargs):
"""
Load a JSON data blob.
Arguments:
path (str): Path to file.
must_exist (bool, otional): If False, return empty dict if file does
not exist.
Returns:
array or dict: JSON data.
Raises:
File404: If path does not ex... | python | {
"resource": ""
} |
q53940 | write_file | train | def write_file(path, data, format=True):
"""
Write JSON data to file.
Arguments:
path (str): Destination.
data (dict or list): JSON serializable data.
format (bool, optional): Pretty-print JSON data.
"""
if format:
fs.write_file(path, format_json(data))
else:
... | python | {
"resource": ""
} |
q53941 | Base.delete_index | train | def delete_index(self,*fields):
"""Delete the index on the specified fields"""
for f in fields:
if not f in self.indices:
raise ValueError,"No index on field %s" %f
for f in fields:
del self.indices[f]
self.commit() | python | {
"resource": ""
} |
q53942 | Base.open | train | def open(self):
"""Open an existing database and load its content into memory"""
# guess protocol
if self.protocol==0:
_in = open(self.name) # don't specify binary mode !
else:
_in = open(self.name,'rb')
self.fields = cPickle.load(_in)
self... | python | {
"resource": ""
} |
q53943 | Base.commit | train | def commit(self):
"""Write the database to a file"""
out = open(self.name,'wb')
cPickle.dump(self.fields,out,self.protocol)
cPickle.dump(self.next_id,out,self.protocol)
cPickle.dump(self.records,out,self.protocol)
cPickle.dump(self.indices,out,self.protocol)
... | python | {
"resource": ""
} |
q53944 | Base.update | train | def update(self,records,**kw):
"""Update one record of a list of records
with new keys and values and update indices"""
# ignore unknown fields
kw = dict([(k,v) for (k,v) in kw.iteritems() if k in self.fields])
if isinstance(records,dict):
records = [ records ]... | python | {
"resource": ""
} |
q53945 | Edge.allows | train | def allows(self, vClass):
"""true if this edge has a lane which allows the given vehicle class"""
for lane in self._lanes:
if vClass in lane._allowed:
return True
return False | python | {
"resource": ""
} |
q53946 | validate | train | def validate(opts):
"""
Client-facing validate method. Checks to see if the passed in opts
argument is either a list or a namespace containing the attribute
'extensions' and runs validations on it accordingly. If opts is neither
of those things, this will raise a ValueError
:param opts: either ... | python | {
"resource": ""
} |
q53947 | ensure_datetime | train | def ensure_datetime(dobj, time_part=None):
"""
Adds time part to dobj if its a date object, returns dobj
untouched if its a datetime object.
"""
if isinstance(dobj, dt.datetime):
return dobj
return dt.datetime.combine(dobj, time_part or dt.time()) | python | {
"resource": ""
} |
q53948 | normalized_path | train | def normalized_path(value):
"""Normalize and expand a shorthand or relative path."""
if not value:
return
norm = os.path.normpath(value)
norm = os.path.abspath(os.path.expanduser(norm))
return norm | python | {
"resource": ""
} |
q53949 | read_from | train | def read_from(value):
"""Read file and return contents."""
path = normalized_path(value)
if not os.path.exists(path):
raise argparse.ArgumentTypeError("%s is not a valid path." % path)
LOG.debug("%s exists.", path)
with open(path, 'r') as reader:
read = reader.read()
return read | python | {
"resource": ""
} |
q53950 | main | train | def main(): # pragma: no cover
"""Simple tests."""
opts = [
Option('--foo'),
Option('--bar'),
Option('--baz'),
Option('--key', group='secret', mutually_exclusive=True),
Option('--key-file', group='secret', mutually_exclusive=True),
Option('--key-thing', group='se... | python | {
"resource": ""
} |
q53951 | Option.add_argument | train | def add_argument(self, parser, permissive=False, **override_kwargs):
"""Add an option to a an argparse parser.
:keyword permissive: when true, build a parser that does not validate
required arguments.
"""
kwargs = {}
required = None
if self.kwargs:
... | python | {
"resource": ""
} |
q53952 | Option.name | train | def name(self):
"""The name of the option as determined from the args."""
for arg in self.args:
if arg.startswith("--"):
return arg[2:].replace("-", "_")
elif arg.startswith("-"):
continue
else:
return arg.replace("-", "... | python | {
"resource": ""
} |
q53953 | Config.init | train | def init(cls, *args, **kwargs):
"""Initialize the config like as you would a regular dict."""
instance = cls()
instance._values.update(dict(*args, **kwargs))
return instance | python | {
"resource": ""
} |
q53954 | Config.prog | train | def prog(self):
"""Program name."""
if not self._prog:
self._prog = self._parser.prog
return self._prog | python | {
"resource": ""
} |
q53955 | Config._metaconfigure | train | def _metaconfigure(self, argv=None):
"""Initialize metaconfig for provisioning self."""
metaconfig = self._get_metaconfig_class()
if not metaconfig:
return
if self.__class__ is metaconfig:
# don't get too meta
return
override = {
'c... | python | {
"resource": ""
} |
q53956 | Config.build_parser | train | def build_parser(self, options=None, permissive=False, **override_kwargs):
"""Construct an argparser from supplied options.
:keyword override_kwargs: keyword arguments to override when calling
parser constructor.
:keyword permissive: when true, build a parser that does not validate
... | python | {
"resource": ""
} |
q53957 | Config.cli_values | train | def cli_values(self, argv):
"""Parse command-line arguments into values.
Parses arguments provided on the command-line (or sys.argv). Only
returns arguments that are explicitly supplied, so we strip out
defaults and validation rules like `required` in this call.
"""
opti... | python | {
"resource": ""
} |
q53958 | Config.validate_config | train | def validate_config(self, values, argv=None, strict=False):
"""Validate all config values through the command-line parser.
This takes all supplied options (which could have been retrieved from a
number of sources (such as CLI, env vars, etc...) and then validates
them by running them th... | python | {
"resource": ""
} |
q53959 | Config.parse_env | train | def parse_env(self, env=None, namespace=None):
"""Parse environment variables."""
env = env or os.environ
results = {}
if not namespace:
namespace = self.prog
namespace = namespace.upper() # pylint: disable=no-member
for option in self._options:
e... | python | {
"resource": ""
} |
q53960 | Config.get_defaults | train | def get_defaults(self):
"""Use argparse to determine and return dict of defaults."""
# dont need 'required' to determine the default
options = [copy.copy(opt) for opt in self._options]
for opt in options:
try:
del opt.kwargs['required']
except KeyE... | python | {
"resource": ""
} |
q53961 | Config.parse_ini | train | def parse_ini(self, paths=None, namespace=None, permissive=False):
"""Parse config files and return configuration options.
Expects array of files that are in ini format.
:param paths:
List of paths to files to parse (uses ConfigParse logic).
If not supplied, uses the in... | python | {
"resource": ""
} |
q53962 | Config.parse_keyring | train | def parse_keyring(self, namespace=None):
"""Find settings from keyring."""
results = {}
if not keyring:
return results
if not namespace:
namespace = self.prog
for option in self._options:
secret = keyring.get_password(namespace, option.name)
... | python | {
"resource": ""
} |
q53963 | MetaConfig.provision | train | def provision(self, conf):
"""Provision this metaconfig's config with what we gathered.
Since Config has native support for ini files, we just need to
let this metaconfig's config know about the ini file we found.
In future scenarios, this is where we would implement logic
spec... | python | {
"resource": ""
} |
q53964 | accept | train | def accept(source_port, destination_port, protocol, raw_addresses):
'''
accepts comma separated addresses or list of addresses
'''
protocol = protocol or 'tcp'
if not isinstance(raw_addresses, list):
raw_addresses = [raw_addresses]
addresses = []
for a in raw_addresses:
if... | python | {
"resource": ""
} |
q53965 | ComponentsModel.initialize_model | train | def initialize_model(self, root_node):
"""
Initializes the Model using given root node.
:param root_node: Graph root node.
:type root_node: DefaultNode
:return: Method success
:rtype: bool
"""
LOGGER.debug("> Initializing model with '{0}' root node.".for... | python | {
"resource": ""
} |
q53966 | LoggerNotificationGateway.announce_job_results | train | def announce_job_results(self,
pacts: List[Pact],
emulator_results_list: List[List[EmulatorResult]],
verification_results_list: List[List[VerificationResult]],
results_published: bool,
... | python | {
"resource": ""
} |
q53967 | _override_dependencies_globals | train | def _override_dependencies_globals():
"""
Overrides dependencies globals.
"""
foundations.globals.constants.Constants.logger = manager.globals.constants.Constants.logger = Constants.logger
foundations.globals.constants.Constants.application_directory = \
manager.globals.constants.Constants.... | python | {
"resource": ""
} |
q53968 | _extend_resources_paths | train | def _extend_resources_paths():
"""
Extend resources paths.
"""
for path in (os.path.join(umbra.__path__[0], Constants.resources_directory),
os.path.join(os.getcwd(), umbra.__name__, Constants.resources_directory)):
path = os.path.normpath(path)
if foundations.common.pat... | python | {
"resource": ""
} |
q53969 | _initialize_logging | train | def _initialize_logging():
"""
Initializes the Application logging.
"""
# Starting the console handler if a terminal is available.
if sys.stdout.isatty() or platform.system() in ("Darwin", "Linux"):
RuntimeGlobals.logging_console_handler = foundations.verbose.get_logging_console_handler()
... | python | {
"resource": ""
} |
q53970 | _initialize_application | train | def _initialize_application():
"""
Initializes the Application.
"""
RuntimeGlobals.application = umbra.ui.common.get_application_instance()
umbra.ui.common.set_window_default_icon(RuntimeGlobals.application)
RuntimeGlobals.reporter = umbra.reporter.install_exception_reporter() | python | {
"resource": ""
} |
q53971 | _initialize_applicationUiFile | train | def _initialize_applicationUiFile():
"""
Initializes the Application ui file.
"""
RuntimeGlobals.ui_file = umbra.ui.common.get_resource_path(UiConstants.ui_file)
if not foundations.common.path_exists(RuntimeGlobals.ui_file):
raise foundations.exceptions.FileExistsError("'{0}' ui file is not... | python | {
"resource": ""
} |
q53972 | show_processing | train | def show_processing(message=""):
"""
Shows processing behavior.
:param message: Operation description.
:type message: unicode
:return: Object.
:rtype: object
"""
def show_processingDecorator(object):
"""
Shows processing behavior.
:param object: Object to decor... | python | {
"resource": ""
} |
q53973 | encapsulate_processing | train | def encapsulate_processing(object):
"""
Encapsulates a processing operation.
:param object: Object to decorate.
:type object: object
:return: Object.
:rtype: object
"""
@functools.wraps(object)
def encapsulate_processing_wrapper(*args, **kwargs):
"""
Encapsulates a ... | python | {
"resource": ""
} |
q53974 | set_user_application_data_directory | train | def set_user_application_data_directory(directory):
"""
Sets the user Application data directory.
:param directory: Starting point for the directories tree creation.
:type directory: unicode
:return: Definition success.
:rtype: bool
"""
LOGGER.debug("> Current Application data director... | python | {
"resource": ""
} |
q53975 | get_command_line_parameters_parser | train | def get_command_line_parameters_parser():
"""
Returns the command line parameters parser.
:return: Parser.
:rtype: Parser
"""
parser = optparse.OptionParser(formatter=optparse.IndentedHelpFormatter(indent_increment=2,
... | python | {
"resource": ""
} |
q53976 | get_logging_file | train | def get_logging_file(maximum_logging_files=10, retries=2 ^ 16):
"""
Returns the logging file path.
:param maximum_logging_files: Maximum allowed logging files in the logging directory.
:type maximum_logging_files: int
:param retries: Number of retries to generate a unique logging file name.
:ty... | python | {
"resource": ""
} |
q53977 | exit | train | def exit(exit_code=0):
"""
Exits the Application.
:param exit_code: Exit code.
:type exit_code: int
"""
for line in SESSION_FOOTER_TEXT:
LOGGER.info(line)
foundations.verbose.remove_logging_handler(RuntimeGlobals.logging_console_handler)
RuntimeGlobals.application.exit(exit_c... | python | {
"resource": ""
} |
q53978 | Umbra.__set_components | train | def __set_components(self, requisite=True):
"""
Sets the Components.
:param requisite: Set only requisite Components.
:type requisite: bool
"""
components = self.__components_manager.list_components()
candidate_components = \
getattr(set(components),... | python | {
"resource": ""
} |
q53979 | Umbra.__set_locals | train | def __set_locals(self):
"""
Sets the locals for the requests_stack.
"""
for globals in (Constants, RuntimeGlobals, UiConstants):
self.__locals[globals.__name__] = globals
self.__locals[Constants.application_name] = self
self.__locals["application"] = self
... | python | {
"resource": ""
} |
q53980 | Umbra.__components_instantiation_callback | train | def __components_instantiation_callback(self, profile):
"""
Defines a callback for Components instantiation.
:param profile: Component Profile.
:type profile: Profile
"""
self.__splashscreen and self.__splashscreen.show_message(
"{0} - {1} | Instantiating {2... | python | {
"resource": ""
} |
q53981 | Umbra.__store_processing_state | train | def __store_processing_state(self):
"""
Stores the processing state.
"""
steps = self.Application_Progress_Status_processing.Processing_progressBar.maximum()
value = self.Application_Progress_Status_processing.Processing_progressBar.value()
message = self.Application_Pro... | python | {
"resource": ""
} |
q53982 | Umbra.__restore_processing_state | train | def __restore_processing_state(self):
"""
Restores the processing state.
"""
steps, value, message, state = self.__processing_state
self.Application_Progress_Status_processing.Processing_progressBar.setRange(0, steps)
self.Application_Progress_Status_processing.Processi... | python | {
"resource": ""
} |
q53983 | Umbra.set_verbosity_level | train | def set_verbosity_level(self, verbosity_level):
"""
Sets the Application verbosity level.
:param verbosity_level: Verbosity level.
:type verbosity_level: int
:return: Method success.
:rtype: bool
:note: The expected verbosity level value is an integer between 0 ... | python | {
"resource": ""
} |
q53984 | Umbra.set_visual_style | train | def set_visual_style(self, full_screen_style=False):
"""
Sets the Application visual style.
:param full_screen_style: Use fullscreen stylesheet file.
:type full_screen_style: bool
:return: Method success.
:rtype: bool
"""
LOGGER.debug("> Setting Applicat... | python | {
"resource": ""
} |
q53985 | Umbra.toggle_full_screen | train | def toggle_full_screen(self, *args):
"""
Toggles Application fullscreen state.
:param \*args: Arguments.
:type \*args: \*
:return: Method success.
:rtype: bool
"""
LOGGER.debug("> Toggling FullScreen state.")
if self.is_full_screen():
... | python | {
"resource": ""
} |
q53986 | Umbra.set_processing_message | train | def set_processing_message(self, message, warning=True):
"""
Sets the processing operation message.
:param message: Operation description.
:type message: unicode
:param warning: Emit warning message.
:type warning: int
:return: Method success.
:rtype: boo... | python | {
"resource": ""
} |
q53987 | Umbra.start_processing | train | def start_processing(self, message, steps=0, warning=True):
"""
Registers the start of a processing operation.
:param message: Operation description.
:type message: unicode
:param steps: Operation steps.
:type steps: int
:param warning: Emit warning message.
... | python | {
"resource": ""
} |
q53988 | Umbra.step_processing | train | def step_processing(self, warning=True):
"""
Steps the processing operation progress indicator.
:param warning: Emit warning message.
:type warning: int
:return: Method success.
:rtype: bool
"""
if not self.__is_processing:
warning and LOGGER... | python | {
"resource": ""
} |
q53989 | Umbra.stop_processing | train | def stop_processing(self, warning=True):
"""
Registers the end of a processing operation.
:param warning: Emit warning message.
:type warning: int
:return: Method success.
:rtype: bool
"""
if not self.__is_processing:
warning and LOGGER.warni... | python | {
"resource": ""
} |
q53990 | Umbra.quit | train | def quit(self, exit_code=0, event=None):
"""
Quits the Application.
:param exit_code: Exit code.
:type exit_code: int
:param event: QEvent.
:type event: QEvent
"""
# --- Running on_close components methods. ---
for component in reversed(self.__co... | python | {
"resource": ""
} |
q53991 | GraphModel.get_attribute | train | def get_attribute(self, node, column):
"""
Returns the given Node attribute associated to the given column.
:param node: Node.
:type node: AbstractCompositeNode or GraphModelNode
:param column: Column.
:type column: int
:return: Attribute.
:rtype: Attribu... | python | {
"resource": ""
} |
q53992 | GraphModel.get_node_index | train | def get_node_index(self, node):
"""
Returns given Node index.
:param node: Node.
:type node: AbstractCompositeNode or GraphModelNode
:return: Index.
:rtype: QModelIndex
"""
if node == self.__root_node:
return QModelIndex()
else:
... | python | {
"resource": ""
} |
q53993 | GraphModel.get_attribute_index | train | def get_attribute_index(self, node, column):
"""
Returns given Node attribute index at given column.
:param node: Node.
:type node: AbstractCompositeNode or GraphModelNode
:param column: Attribute column.
:type column: int
:return: Index.
:rtype: QModelIn... | python | {
"resource": ""
} |
q53994 | GraphModel.find_node | train | def find_node(self, attribute):
"""
Returns the Node with given attribute.
:param attribute: Attribute.
:type attribute: GraphModelAttribute
:return: Node.
:rtype: GraphModelNode
"""
for model in GraphModel._GraphModel__models_instances.itervalues():
... | python | {
"resource": ""
} |
q53995 | GraphModel.enable_model_triggers | train | def enable_model_triggers(self, state):
"""
Enables Model Nodes and attributes triggers.
:param state: Inform model state.
:type state: bool
:return: Method success.
:rtype: bool
"""
for node in foundations.walkers.nodes_walker(self.root_node):
... | python | {
"resource": ""
} |
q53996 | ComponentsManagerUi.on_startup | train | def on_startup(self):
"""
Defines the slot triggered by Framework startup.
:return: Method success.
:rtype: bool
"""
LOGGER.debug("> Calling '{0}' Component Framework 'on_startup' method.".format(self.__class__.__name__))
self.refresh_nodes.emit()
retur... | python | {
"resource": ""
} |
q53997 | ComponentsManagerUi.__store_deactivated_components | train | def __store_deactivated_components(self):
"""
Stores deactivated Components in settings file.
"""
deactivated_components = []
for node in foundations.walkers.nodes_walker(self.__model.root_node):
if node.family == "Component":
node.component.interface... | python | {
"resource": ""
} |
q53998 | ComponentsManagerUi.activate_components_ui | train | def activate_components_ui(self):
"""
Activates user selected Components.
:return: Method success.
:rtype: bool
:note: May require user interaction.
"""
selected_components = self.get_selected_components()
self.__engine.start_processing("Activating Com... | python | {
"resource": ""
} |
q53999 | ComponentsManagerUi.deactivate_components_ui | train | def deactivate_components_ui(self):
"""
Deactivates user selected Components.
:return: Method success.
:rtype: bool
:note: May require user interaction.
"""
selected_components = self.get_selected_components()
self.__engine.start_processing("Deactivati... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.