Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
DQN.finish_initialization
(self)
Wait until policy workers are fully initialized.
Wait until policy workers are fully initialized.
def finish_initialization(self): """Wait until policy workers are fully initialized.""" for policy_id, workers in self.policy_workers.items(): for w in workers: log.debug('Waiting for policy worker %d-%d to finish initialization...', policy_id, w.worker_idx) w...
[ "def", "finish_initialization", "(", "self", ")", ":", "for", "policy_id", ",", "workers", "in", "self", ".", "policy_workers", ".", "items", "(", ")", ":", "for", "w", "in", "workers", ":", "log", ".", "debug", "(", "'Waiting for policy worker %d-%d to finish...
[ 427, 4 ]
[ 433, 86 ]
python
en
['en', 'en', 'en']
True
DQN.process_report
(self, report)
Process stats from various types of workers.
Process stats from various types of workers.
def process_report(self, report): """Process stats from various types of workers.""" if 'policy_id' in report: policy_id = report['policy_id'] if 'learner_env_steps' in report: if policy_id in self.env_steps: delta = report['learner_env_steps...
[ "def", "process_report", "(", "self", ",", "report", ")", ":", "if", "'policy_id'", "in", "report", ":", "policy_id", "=", "report", "[", "'policy_id'", "]", "if", "'learner_env_steps'", "in", "report", ":", "if", "policy_id", "in", "self", ".", "env_steps",...
[ 435, 4 ]
[ 471, 46 ]
python
en
['en', 'en', 'en']
True
DQN.report
(self)
Called periodically (every X seconds, see report_interval). Print experiment stats (FPS, avg rewards) to console and dump TF summaries collected from workers to disk.
Called periodically (every X seconds, see report_interval). Print experiment stats (FPS, avg rewards) to console and dump TF summaries collected from workers to disk.
def report(self): """ Called periodically (every X seconds, see report_interval). Print experiment stats (FPS, avg rewards) to console and dump TF summaries collected from workers to disk. """ if len(self.env_steps) < self.cfg.num_policies: return now = time...
[ "def", "report", "(", "self", ")", ":", "if", "len", "(", "self", ".", "env_steps", ")", "<", "self", ".", "cfg", ".", "num_policies", ":", "return", "now", "=", "time", ".", "time", "(", ")", "self", ".", "fps_stats", ".", "append", "(", "(", "n...
[ 473, 4 ]
[ 506, 56 ]
python
en
['en', 'error', 'th']
False
DQN.run
(self)
This function contains the main loop of the algorithm, as well as initialization/cleanup code. :return: ExperimentStatus (SUCCESS, FAILURE, INTERRUPTED). Useful in testing.
This function contains the main loop of the algorithm, as well as initialization/cleanup code.
def run(self): """ This function contains the main loop of the algorithm, as well as initialization/cleanup code. :return: ExperimentStatus (SUCCESS, FAILURE, INTERRUPTED). Useful in testing. """ status = ExperimentStatus.SUCCESS if os.path.isfile(done_filename(self.cf...
[ "def", "run", "(", "self", ")", ":", "status", "=", "ExperimentStatus", ".", "SUCCESS", "if", "os", ".", "path", ".", "isfile", "(", "done_filename", "(", "self", ".", "cfg", ")", ")", ":", "log", ".", "warning", "(", "'Training already finished! Remove \"...
[ 583, 4 ]
[ 666, 21 ]
python
en
['en', 'error', 'th']
False
areRowsEqual
(rows, expected)
expected is a list [({name:'lion',...}, {var_name:True,...})]
expected is a list [({name:'lion',...}, {var_name:True,...})]
def areRowsEqual(rows, expected): """expected is a list [({name:'lion',...}, {var_name:True,...})] """ rows = list(rows) if len(rows) != len(expected): print 'got len %d, expected %d' % (len(rows), len(expected)) return False for attrs_dict, vars_dict in expected: for r i...
[ "def", "areRowsEqual", "(", "rows", ",", "expected", ")", ":", "rows", "=", "list", "(", "rows", ")", "if", "len", "(", "rows", ")", "!=", "len", "(", "expected", ")", ":", "print", "'got len %d, expected %d'", "%", "(", "len", "(", "rows", ")", ",",...
[ 21, 0 ]
[ 39, 15 ]
python
en
['en', 'en', 'en']
True
TestJeevesModel.setUp
(self)
self.x = JeevesLib.mkLabel() self.y = JeevesLib.mkLabel() JeevesLib.restrict(self.x, lambda (a,_) : a) JeevesLib.restrict(self.y, lambda (_,a) : a) # Add elements to the database. print >> sys.stderr, "adding fox" Animal.objects.create(name='fox', so...
self.x = JeevesLib.mkLabel() self.y = JeevesLib.mkLabel() JeevesLib.restrict(self.x, lambda (a,_) : a) JeevesLib.restrict(self.y, lambda (_,a) : a)
def setUp(self): JeevesLib.init() self.f = open('log.txt', 'w') JeevesLib.set_log_policies(self.f) Animal.objects.create(name='lion', sound='roar') # Animal.objects.create(name='cat', sound='meow') ''' self.x = JeevesLib.mkLabel() self.y = JeevesLib.mkLa...
[ "def", "setUp", "(", "self", ")", ":", "JeevesLib", ".", "init", "(", ")", "self", ".", "f", "=", "open", "(", "'log.txt'", ",", "'w'", ")", "JeevesLib", ".", "set_log_policies", "(", "self", ".", "f", ")", "Animal", ".", "objects", ".", "create", ...
[ 45, 4 ]
[ 73, 11 ]
python
en
['en', 'error', 'th']
False
TestJeevesModel.testWrite
(self)
fox = Animal._objects_ordinary.filter(name='fox').filter( jeeves_vars=';%s=1;'%self.x.name).all()[0] self.assertEquals(fox.sound, 'Hatee-hatee-hatee-ho!') fox = Animal._objects_ordinary.filter(name='fox').filter( jeeves_vars=';%s=0;'%self.x.name).all()[0] ...
fox = Animal._objects_ordinary.filter(name='fox').filter( jeeves_vars=';%s=1;'%self.x.name).all()[0] self.assertEquals(fox.sound, 'Hatee-hatee-hatee-ho!')
def testWrite(self): lion = Animal.objects.get(name='lion') # self.assertEquals(JeevesLib.concretize(lion, lion.name), 'lion') # self.assertEquals(JeevesLib.concretize(lion, lion.sound), 'roar') ''' fox = Animal._objects_ordinary.filter(name='fox').filter( jeeves...
[ "def", "testWrite", "(", "self", ")", ":", "lion", "=", "Animal", ".", "objects", ".", "get", "(", "name", "=", "'lion'", ")", "# self.assertEquals(JeevesLib.concretize(lion, lion.name), 'lion')", "# self.assertEquals(JeevesLib.concretize(lion, lion.sound), 'roar')" ]
[ 94, 4 ]
[ 116, 11 ]
python
en
['en', 'error', 'th']
False
Matcher.__init__
(self, cls)
@param cls: A class object. @type cls: I{classobj}
def __init__(self, cls): """ @param cls: A class object. @type cls: I{classobj} """ self.cls = cls
[ "def", "__init__", "(", "self", ",", "cls", ")", ":", "self", ".", "cls", "=", "cls" ]
[ 38, 4 ]
[ 43, 22 ]
python
en
['en', 'error', 'th']
False
ContentAppender.__init__
(self, marshaller)
@param marshaller: A marshaller. @type marshaller: L{suds.mx.core.Core}
def __init__(self, marshaller): """ @param marshaller: A marshaller. @type marshaller: L{suds.mx.core.Core} """ self.default = PrimativeAppender(marshaller) self.appenders = ( (Matcher(None), NoneAppender(marshaller)), (Matcher(null...
[ "def", "__init__", "(", "self", ",", "marshaller", ")", ":", "self", ".", "default", "=", "PrimativeAppender", "(", "marshaller", ")", "self", ".", "appenders", "=", "(", "(", "Matcher", "(", "None", ")", ",", "NoneAppender", "(", "marshaller", ")", ")",...
[ 61, 4 ]
[ 86, 9 ]
python
en
['en', 'error', 'th']
False
ContentAppender.append
(self, parent, content)
Select an appender and append the content to parent. @param parent: A parent node. @type parent: L{Element} @param content: The content to append. @type content: L{Content}
Select an appender and append the content to parent.
def append(self, parent, content): """ Select an appender and append the content to parent. @param parent: A parent node. @type parent: L{Element} @param content: The content to append. @type content: L{Content} """ appender = self.default for a in...
[ "def", "append", "(", "self", ",", "parent", ",", "content", ")", ":", "appender", "=", "self", ".", "default", "for", "a", "in", "self", ".", "appenders", ":", "if", "a", "[", "0", "]", "==", "content", ".", "value", ":", "appender", "=", "a", "...
[ 88, 4 ]
[ 101, 40 ]
python
en
['en', 'error', 'th']
False
Appender.__init__
(self, marshaller)
@param marshaller: A marshaller. @type marshaller: L{suds.mx.core.Core}
def __init__(self, marshaller): """ @param marshaller: A marshaller. @type marshaller: L{suds.mx.core.Core} """ self.marshaller = marshaller
[ "def", "__init__", "(", "self", ",", "marshaller", ")", ":", "self", ".", "marshaller", "=", "marshaller" ]
[ 111, 4 ]
[ 116, 37 ]
python
en
['en', 'error', 'th']
False
Appender.node
(self, content)
Create and return an XML node that is qualified using the I{type}. Also, make sure all referenced namespace prefixes are declared. @param content: The content for which proccessing has ended. @type content: L{Object} @return: A new node. @rtype: L{Element} ...
Create and return an XML node that is qualified using the I{type}. Also, make sure all referenced namespace prefixes are declared.
def node(self, content): """ Create and return an XML node that is qualified using the I{type}. Also, make sure all referenced namespace prefixes are declared. @param content: The content for which proccessing has ended. @type content: L{Object} @return: A new no...
[ "def", "node", "(", "self", ",", "content", ")", ":", "return", "self", ".", "marshaller", ".", "node", "(", "content", ")" ]
[ 118, 4 ]
[ 128, 44 ]
python
en
['en', 'error', 'th']
False
Appender.setnil
(self, node, content)
Set the value of the I{node} to nill. @param node: A I{nil} node. @type node: L{Element} @param content: The content for which proccessing has ended. @type content: L{Object}
Set the value of the I{node} to nill.
def setnil(self, node, content): """ Set the value of the I{node} to nill. @param node: A I{nil} node. @type node: L{Element} @param content: The content for which proccessing has ended. @type content: L{Object} """ self.marshaller.setnil(node, content)
[ "def", "setnil", "(", "self", ",", "node", ",", "content", ")", ":", "self", ".", "marshaller", ".", "setnil", "(", "node", ",", "content", ")" ]
[ 130, 4 ]
[ 138, 45 ]
python
en
['en', 'error', 'th']
False
Appender.setdefault
(self, node, content)
Set the value of the I{node} to a default value. @param node: A I{nil} node. @type node: L{Element} @param content: The content for which proccessing has ended. @type content: L{Object} @return: The default.
Set the value of the I{node} to a default value.
def setdefault(self, node, content): """ Set the value of the I{node} to a default value. @param node: A I{nil} node. @type node: L{Element} @param content: The content for which proccessing has ended. @type content: L{Object} @return: The default. """ ...
[ "def", "setdefault", "(", "self", ",", "node", ",", "content", ")", ":", "return", "self", ".", "marshaller", ".", "setdefault", "(", "node", ",", "content", ")" ]
[ 140, 4 ]
[ 149, 56 ]
python
en
['en', 'error', 'th']
False
Appender.optional
(self, content)
Get whether the specified content is optional. @param content: The content which to check. @type content: L{Content}
Get whether the specified content is optional.
def optional(self, content): """ Get whether the specified content is optional. @param content: The content which to check. @type content: L{Content} """ return self.marshaller.optional(content)
[ "def", "optional", "(", "self", ",", "content", ")", ":", "return", "self", ".", "marshaller", ".", "optional", "(", "content", ")" ]
[ 151, 4 ]
[ 157, 48 ]
python
en
['en', 'error', 'th']
False
Appender.suspend
(self, content)
Notify I{marshaller} that appending this content has suspended. @param content: The content for which proccessing has been suspended. @type content: L{Object}
Notify I{marshaller} that appending this content has suspended.
def suspend(self, content): """ Notify I{marshaller} that appending this content has suspended. @param content: The content for which proccessing has been suspended. @type content: L{Object} """ self.marshaller.suspend(content)
[ "def", "suspend", "(", "self", ",", "content", ")", ":", "self", ".", "marshaller", ".", "suspend", "(", "content", ")" ]
[ 159, 4 ]
[ 165, 40 ]
python
en
['en', 'error', 'th']
False
Appender.resume
(self, content)
Notify I{marshaller} that appending this content has resumed. @param content: The content for which proccessing has been resumed. @type content: L{Object}
Notify I{marshaller} that appending this content has resumed.
def resume(self, content): """ Notify I{marshaller} that appending this content has resumed. @param content: The content for which proccessing has been resumed. @type content: L{Object} """ self.marshaller.resume(content)
[ "def", "resume", "(", "self", ",", "content", ")", ":", "self", ".", "marshaller", ".", "resume", "(", "content", ")" ]
[ 167, 4 ]
[ 173, 39 ]
python
en
['en', 'error', 'th']
False
Appender.append
(self, parent, content)
Append the specified L{content} to the I{parent}. @param content: The content to append. @type content: L{Object}
Append the specified L{content} to the I{parent}.
def append(self, parent, content): """ Append the specified L{content} to the I{parent}. @param content: The content to append. @type content: L{Object} """ self.marshaller.append(parent, content)
[ "def", "append", "(", "self", ",", "parent", ",", "content", ")", ":", "self", ".", "marshaller", ".", "append", "(", "parent", ",", "content", ")" ]
[ 175, 4 ]
[ 181, 47 ]
python
en
['en', 'error', 'th']
False
Paper.policy_paperlabel
(self, ctxt)
Policy for seeing author of papers.
Policy for seeing author of papers.
def policy_paperlabel(self, ctxt): ''' Policy for seeing author of papers. ''' if phase == 'final': return True else: # See if there is a PC conflict. try: conflict = PaperPCConflict.objects.get(paper=self, pc=ctxt) ...
[ "def", "policy_paperlabel", "(", "self", ",", "ctxt", ")", ":", "if", "phase", "==", "'final'", ":", "return", "True", "else", ":", "# See if there is a PC conflict.", "try", ":", "conflict", "=", "PaperPCConflict", ".", "objects", ".", "get", "(", "paper", ...
[ 44, 4 ]
[ 57, 88 ]
python
en
['en', 'error', 'th']
False
format_for_columns
(pkgs, options)
Convert the package data into something usable by output_package_listing_columns.
Convert the package data into something usable by output_package_listing_columns.
def format_for_columns(pkgs, options): # type: (List[Distribution], Values) -> Tuple[List[List[str]], List[str]] """ Convert the package data into something usable by output_package_listing_columns. """ running_outdated = options.outdated # Adjust the header for the `pip list --outdated` cas...
[ "def", "format_for_columns", "(", "pkgs", ",", "options", ")", ":", "# type: (List[Distribution], Values) -> Tuple[List[List[str]], List[str]]", "running_outdated", "=", "options", ".", "outdated", "# Adjust the header for the `pip list --outdated` case.", "if", "running_outdated", ...
[ 266, 0 ]
[ 301, 23 ]
python
en
['en', 'error', 'th']
False
ListCommand._build_package_finder
(self, options, session)
Create a package finder appropriate to this list command.
Create a package finder appropriate to this list command.
def _build_package_finder(self, options, session): # type: (Values, PipSession) -> PackageFinder """ Create a package finder appropriate to this list command. """ link_collector = LinkCollector.create(session, options=options) # Pass allow_yanked=False to ignore yanked v...
[ "def", "_build_package_finder", "(", "self", ",", "options", ",", "session", ")", ":", "# type: (Values, PipSession) -> PackageFinder", "link_collector", "=", "LinkCollector", ".", "create", "(", "session", ",", "options", "=", "options", ")", "# Pass allow_yanked=False...
[ 122, 4 ]
[ 138, 9 ]
python
en
['en', 'error', 'th']
False
midi_to_note_sequence
(midi_data)
Convert MIDI file contents to a NoteSequence. Converts a MIDI file encoded as a string into a NoteSequence. Decoding errors are very common when working with large sets of MIDI files, so be sure to handle MIDIConversionError exceptions. Args: midi_data: A string containing the contents of a MIDI file or p...
Convert MIDI file contents to a NoteSequence.
def midi_to_note_sequence(midi_data): """Convert MIDI file contents to a NoteSequence. Converts a MIDI file encoded as a string into a NoteSequence. Decoding errors are very common when working with large sets of MIDI files, so be sure to handle MIDIConversionError exceptions. Args: midi_data: A string ...
[ "def", "midi_to_note_sequence", "(", "midi_data", ")", ":", "# In practice many MIDI files cannot be decoded with pretty_midi. Catch all", "# errors here and try to log a meaningful message. So many different", "# exceptions are raised in pretty_midi.PrettyMidi that it is cumbersome to", "# catch ...
[ 42, 0 ]
[ 169, 17 ]
python
en
['en', 'en', 'en']
True
midi_file_to_note_sequence
(midi_file)
Converts MIDI file to a NoteSequence. Args: midi_file: A string path to a MIDI file. Returns: A NoteSequence. Raises: MIDIConversionError: Invalid midi_file.
Converts MIDI file to a NoteSequence.
def midi_file_to_note_sequence(midi_file): """Converts MIDI file to a NoteSequence. Args: midi_file: A string path to a MIDI file. Returns: A NoteSequence. Raises: MIDIConversionError: Invalid midi_file. """ with open(midi_file, 'rb') as f: midi_as_string = f.read() return midi_to_not...
[ "def", "midi_file_to_note_sequence", "(", "midi_file", ")", ":", "with", "open", "(", "midi_file", ",", "'rb'", ")", "as", "f", ":", "midi_as_string", "=", "f", ".", "read", "(", ")", "return", "midi_to_note_sequence", "(", "midi_as_string", ")" ]
[ 172, 0 ]
[ 186, 48 ]
python
en
['en', 'en', 'en']
True
note_sequence_to_midi_file
(sequence, output_file, drop_events_n_seconds_after_last_note=None)
Convert NoteSequence to a MIDI file on disk. Time is stored in the NoteSequence in absolute values (seconds) as opposed to relative values (MIDI ticks). When the NoteSequence is translated back to MIDI the absolute time is retained. The tempo map is also recreated. Args: sequence: A NoteSequence. outp...
Convert NoteSequence to a MIDI file on disk.
def note_sequence_to_midi_file(sequence, output_file, drop_events_n_seconds_after_last_note=None): """Convert NoteSequence to a MIDI file on disk. Time is stored in the NoteSequence in absolute values (seconds) as opposed to relative values (MIDI ticks). When the NoteSequence is tr...
[ "def", "note_sequence_to_midi_file", "(", "sequence", ",", "output_file", ",", "drop_events_n_seconds_after_last_note", "=", "None", ")", ":", "pretty_midi_object", "=", "note_sequence_to_pretty_midi", "(", "sequence", ",", "drop_events_n_seconds_after_last_note", ")", "prett...
[ 189, 0 ]
[ 206, 51 ]
python
en
['en', 'en', 'en']
True
note_sequence_to_pretty_midi
( sequence, drop_events_n_seconds_after_last_note=None)
Convert NoteSequence to a PrettyMIDI. Time is stored in the NoteSequence in absolute values (seconds) as opposed to relative values (MIDI ticks). When the NoteSequence is translated back to PrettyMIDI the absolute time is retained. The tempo map is also recreated. Args: sequence: A NoteSequence. drop_...
Convert NoteSequence to a PrettyMIDI.
def note_sequence_to_pretty_midi( sequence, drop_events_n_seconds_after_last_note=None): """Convert NoteSequence to a PrettyMIDI. Time is stored in the NoteSequence in absolute values (seconds) as opposed to relative values (MIDI ticks). When the NoteSequence is translated back to PrettyMIDI the absolute t...
[ "def", "note_sequence_to_pretty_midi", "(", "sequence", ",", "drop_events_n_seconds_after_last_note", "=", "None", ")", ":", "ticks_per_quarter", "=", "sequence", ".", "ticks_per_quarter", "or", "constants", ".", "STANDARD_PPQ", "max_event_time", "=", "None", "if", "dro...
[ 209, 0 ]
[ 337, 11 ]
python
en
['en', 'gl', 'en']
True
midi_to_sequence_proto
(midi_data)
Renamed to midi_to_note_sequence.
Renamed to midi_to_note_sequence.
def midi_to_sequence_proto(midi_data): """Renamed to midi_to_note_sequence.""" return midi_to_note_sequence(midi_data)
[ "def", "midi_to_sequence_proto", "(", "midi_data", ")", ":", "return", "midi_to_note_sequence", "(", "midi_data", ")" ]
[ 340, 0 ]
[ 342, 41 ]
python
en
['en', 'en', 'sw']
True
sequence_proto_to_pretty_midi
(sequence, drop_events_n_seconds_after_last_note=None)
Renamed to note_sequence_to_pretty_midi.
Renamed to note_sequence_to_pretty_midi.
def sequence_proto_to_pretty_midi(sequence, drop_events_n_seconds_after_last_note=None): """Renamed to note_sequence_to_pretty_midi.""" return note_sequence_to_pretty_midi(sequence, drop_events_n_seconds_after_last_note)
[ "def", "sequence_proto_to_pretty_midi", "(", "sequence", ",", "drop_events_n_seconds_after_last_note", "=", "None", ")", ":", "return", "note_sequence_to_pretty_midi", "(", "sequence", ",", "drop_events_n_seconds_after_last_note", ")" ]
[ 345, 0 ]
[ 349, 76 ]
python
en
['en', 'en', 'en']
True
midi_file_to_sequence_proto
(midi_file)
Renamed to midi_file_to_note_sequence.
Renamed to midi_file_to_note_sequence.
def midi_file_to_sequence_proto(midi_file): """Renamed to midi_file_to_note_sequence.""" return midi_file_to_note_sequence(midi_file)
[ "def", "midi_file_to_sequence_proto", "(", "midi_file", ")", ":", "return", "midi_file_to_note_sequence", "(", "midi_file", ")" ]
[ 352, 0 ]
[ 354, 46 ]
python
en
['en', 'en', 'sw']
True
sequence_proto_to_midi_file
(sequence, output_file, drop_events_n_seconds_after_last_note=None)
Renamed to note_sequence_to_midi_file.
Renamed to note_sequence_to_midi_file.
def sequence_proto_to_midi_file(sequence, output_file, drop_events_n_seconds_after_last_note=None): """Renamed to note_sequence_to_midi_file.""" return note_sequence_to_midi_file(sequence, output_file, drop_events_n_seconds_after_last_note)
[ "def", "sequence_proto_to_midi_file", "(", "sequence", ",", "output_file", ",", "drop_events_n_seconds_after_last_note", "=", "None", ")", ":", "return", "note_sequence_to_midi_file", "(", "sequence", ",", "output_file", ",", "drop_events_n_seconds_after_last_note", ")" ]
[ 357, 0 ]
[ 361, 74 ]
python
en
['en', 'en', 'en']
True
PyPIRCCommand._get_rc_file
(self)
Returns rc file path.
Returns rc file path.
def _get_rc_file(self): """Returns rc file path.""" return os.path.join(os.path.expanduser('~'), '.pypirc')
[ "def", "_get_rc_file", "(", "self", ")", ":", "return", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "expanduser", "(", "'~'", ")", ",", "'.pypirc'", ")" ]
[ 37, 4 ]
[ 39, 63 ]
python
en
['fr', 'ja', 'en']
False
PyPIRCCommand._store_pypirc
(self, username, password)
Creates a default .pypirc file.
Creates a default .pypirc file.
def _store_pypirc(self, username, password): """Creates a default .pypirc file.""" rc = self._get_rc_file() with os.fdopen(os.open(rc, os.O_CREAT | os.O_WRONLY, 0o600), 'w') as f: f.write(DEFAULT_PYPIRC % (username, password))
[ "def", "_store_pypirc", "(", "self", ",", "username", ",", "password", ")", ":", "rc", "=", "self", ".", "_get_rc_file", "(", ")", "with", "os", ".", "fdopen", "(", "os", ".", "open", "(", "rc", ",", "os", ".", "O_CREAT", "|", "os", ".", "O_WRONLY"...
[ 41, 4 ]
[ 45, 58 ]
python
en
['es', 'fr', 'en']
False
PyPIRCCommand._read_pypirc
(self)
Reads the .pypirc file.
Reads the .pypirc file.
def _read_pypirc(self): """Reads the .pypirc file.""" rc = self._get_rc_file() if os.path.exists(rc): self.announce('Using PyPI login from %s' % rc) repository = self.repository or self.DEFAULT_REPOSITORY config = RawConfigParser() config.read(rc)...
[ "def", "_read_pypirc", "(", "self", ")", ":", "rc", "=", "self", ".", "_get_rc_file", "(", ")", "if", "os", ".", "path", ".", "exists", "(", "rc", ")", ":", "self", ".", "announce", "(", "'Using PyPI login from %s'", "%", "rc", ")", "repository", "=", ...
[ 47, 4 ]
[ 109, 17 ]
python
en
['en', 'en', 'en']
True
PyPIRCCommand._read_pypi_response
(self, response)
Read and decode a PyPI HTTP response.
Read and decode a PyPI HTTP response.
def _read_pypi_response(self, response): """Read and decode a PyPI HTTP response.""" import cgi content_type = response.getheader('content-type', 'text/plain') encoding = cgi.parse_header(content_type)[1].get('charset', 'ascii') return response.read().decode(encoding)
[ "def", "_read_pypi_response", "(", "self", ",", "response", ")", ":", "import", "cgi", "content_type", "=", "response", ".", "getheader", "(", "'content-type'", ",", "'text/plain'", ")", "encoding", "=", "cgi", ".", "parse_header", "(", "content_type", ")", "[...
[ 111, 4 ]
[ 116, 47 ]
python
en
['en', 'en', 'en']
True
PyPIRCCommand.initialize_options
(self)
Initialize options.
Initialize options.
def initialize_options(self): """Initialize options.""" self.repository = None self.realm = None self.show_response = 0
[ "def", "initialize_options", "(", "self", ")", ":", "self", ".", "repository", "=", "None", "self", ".", "realm", "=", "None", "self", ".", "show_response", "=", "0" ]
[ 118, 4 ]
[ 122, 30 ]
python
en
['en', 'en', 'en']
False
PyPIRCCommand.finalize_options
(self)
Finalizes options.
Finalizes options.
def finalize_options(self): """Finalizes options.""" if self.repository is None: self.repository = self.DEFAULT_REPOSITORY if self.realm is None: self.realm = self.DEFAULT_REALM
[ "def", "finalize_options", "(", "self", ")", ":", "if", "self", ".", "repository", "is", "None", ":", "self", ".", "repository", "=", "self", ".", "DEFAULT_REPOSITORY", "if", "self", ".", "realm", "is", "None", ":", "self", ".", "realm", "=", "self", "...
[ 124, 4 ]
[ 129, 43 ]
python
en
['en', 'en', 'en']
False
is_token_valid
(token, margin=None)
Timezone-aware checking of the auth token's expiration timestamp. Returns ``True`` if the token has not yet expired, otherwise ``False``. :param token: The openstack_auth.user.Token instance to check :param margin: A time margin in seconds to subtract from the real token's validity. An exam...
Timezone-aware checking of the auth token's expiration timestamp.
def is_token_valid(token, margin=None): """Timezone-aware checking of the auth token's expiration timestamp. Returns ``True`` if the token has not yet expired, otherwise ``False``. :param token: The openstack_auth.user.Token instance to check :param margin: A time margin in seconds to subtract...
[ "def", "is_token_valid", "(", "token", ",", "margin", "=", "None", ")", ":", "expiration", "=", "token", ".", "expires", "# In case we get an unparseable expiration timestamp, return False", "# so you can't have a \"forever\" token just by breaking the expires param.", "if", "exp...
[ 74, 0 ]
[ 100, 38 ]
python
en
['en', 'en', 'en']
True
allow_expired_passowrd_change
()
Checks if users should be able to change their expired passwords.
Checks if users should be able to change their expired passwords.
def allow_expired_passowrd_change(): """Checks if users should be able to change their expired passwords.""" return getattr(settings, 'ALLOW_USERS_CHANGE_EXPIRED_PASSWORD', True)
[ "def", "allow_expired_passowrd_change", "(", ")", ":", "return", "getattr", "(", "settings", ",", "'ALLOW_USERS_CHANGE_EXPIRED_PASSWORD'", ",", "True", ")" ]
[ 136, 0 ]
[ 138, 73 ]
python
en
['en', 'en', 'en']
True
is_websso_enabled
()
Websso is supported in Keystone version 3.
Websso is supported in Keystone version 3.
def is_websso_enabled(): """Websso is supported in Keystone version 3.""" return settings.WEBSSO_ENABLED
[ "def", "is_websso_enabled", "(", ")", ":", "return", "settings", ".", "WEBSSO_ENABLED" ]
[ 141, 0 ]
[ 143, 34 ]
python
en
['en', 'en', 'en']
True
is_websso_default_redirect
()
Checks if the websso default redirect is available. As with websso, this is only supported in Keystone version 3.
Checks if the websso default redirect is available.
def is_websso_default_redirect(): """Checks if the websso default redirect is available. As with websso, this is only supported in Keystone version 3. """ websso_default_redirect = settings.WEBSSO_DEFAULT_REDIRECT keystonev3_plus = (get_keystone_version() >= 3) return websso_default_redirect an...
[ "def", "is_websso_default_redirect", "(", ")", ":", "websso_default_redirect", "=", "settings", ".", "WEBSSO_DEFAULT_REDIRECT", "keystonev3_plus", "=", "(", "get_keystone_version", "(", ")", ">=", "3", ")", "return", "websso_default_redirect", "and", "keystonev3_plus" ]
[ 146, 0 ]
[ 153, 54 ]
python
en
['en', 'en', 'en']
True
build_absolute_uri
(request, relative_url)
Ensure absolute_uri are relative to WEBROOT.
Ensure absolute_uri are relative to WEBROOT.
def build_absolute_uri(request, relative_url): """Ensure absolute_uri are relative to WEBROOT.""" webroot = settings.WEBROOT if webroot.endswith("/") and relative_url.startswith("/"): webroot = webroot[:-1] return request.build_absolute_uri(webroot + relative_url)
[ "def", "build_absolute_uri", "(", "request", ",", "relative_url", ")", ":", "webroot", "=", "settings", ".", "WEBROOT", "if", "webroot", ".", "endswith", "(", "\"/\"", ")", "and", "relative_url", ".", "startswith", "(", "\"/\"", ")", ":", "webroot", "=", "...
[ 168, 0 ]
[ 174, 61 ]
python
en
['en', 'en', 'en']
True
get_websso_url
(request, auth_url, websso_auth)
Return the keystone endpoint for initiating WebSSO. Generate the keystone WebSSO endpoint that will redirect the user to the login page of the federated identity provider. Based on the authentication type selected by the user in the login form, it will construct the keystone WebSSO endpoint. :par...
Return the keystone endpoint for initiating WebSSO.
def get_websso_url(request, auth_url, websso_auth): """Return the keystone endpoint for initiating WebSSO. Generate the keystone WebSSO endpoint that will redirect the user to the login page of the federated identity provider. Based on the authentication type selected by the user in the login form...
[ "def", "get_websso_url", "(", "request", ",", "auth_url", ",", "websso_auth", ")", ":", "origin", "=", "build_absolute_uri", "(", "request", ",", "'/auth/websso/'", ")", "idp_mapping", "=", "settings", ".", "WEBSSO_IDP_MAPPING", "idp_id", ",", "protocol_id", "=", ...
[ 177, 0 ]
[ 252, 14 ]
python
en
['en', 'en', 'en']
True
has_in_url_path
(url, subs)
Test if any of `subs` strings is present in the `url` path.
Test if any of `subs` strings is present in the `url` path.
def has_in_url_path(url, subs): """Test if any of `subs` strings is present in the `url` path.""" scheme, netloc, path, query, fragment = urlparse.urlsplit(url) return any([sub in path for sub in subs])
[ "def", "has_in_url_path", "(", "url", ",", "subs", ")", ":", "scheme", ",", "netloc", ",", "path", ",", "query", ",", "fragment", "=", "urlparse", ".", "urlsplit", "(", "url", ")", "return", "any", "(", "[", "sub", "in", "path", "for", "sub", "in", ...
[ 255, 0 ]
[ 258, 45 ]
python
en
['en', 'en', 'en']
True
url_path_replace
(url, old, new, count=None)
Return a copy of url with replaced path. Return a copy of url with all occurrences of old replaced by new in the url path. If the optional argument count is given, only the first count occurrences are replaced.
Return a copy of url with replaced path.
def url_path_replace(url, old, new, count=None): """Return a copy of url with replaced path. Return a copy of url with all occurrences of old replaced by new in the url path. If the optional argument count is given, only the first count occurrences are replaced. """ args = [] scheme, netlo...
[ "def", "url_path_replace", "(", "url", ",", "old", ",", "new", ",", "count", "=", "None", ")", ":", "args", "=", "[", "]", "scheme", ",", "netloc", ",", "path", ",", "query", ",", "fragment", "=", "urlparse", ".", "urlsplit", "(", "url", ")", "if",...
[ 261, 0 ]
[ 273, 72 ]
python
en
['en', 'en', 'en']
True
_augment_url_with_version
(auth_url)
Optionally augment auth_url path with version suffix. Check if path component already contains version suffix and if it does not, append version suffix to the end of path, not erasing the previous path contents, since keystone web endpoint (like /identity) could be there. Keystone version needs to be a...
Optionally augment auth_url path with version suffix.
def _augment_url_with_version(auth_url): """Optionally augment auth_url path with version suffix. Check if path component already contains version suffix and if it does not, append version suffix to the end of path, not erasing the previous path contents, since keystone web endpoint (like /identity) co...
[ "def", "_augment_url_with_version", "(", "auth_url", ")", ":", "if", "has_in_url_path", "(", "auth_url", ",", "[", "\"/v3\"", "]", ")", ":", "return", "auth_url", "return", "url_path_append", "(", "auth_url", ",", "\"/v3\"", ")" ]
[ 282, 0 ]
[ 295, 43 ]
python
en
['en', 'en', 'en']
True
fix_auth_url_version_prefix
(auth_url)
Fix up the auth url if an invalid or no version prefix was given. Fix the URL to say v3 in this case and add version if it is missing entirely. This should be smarter and use discovery. Until version discovery is implemented we need this method to get everything working.
Fix up the auth url if an invalid or no version prefix was given.
def fix_auth_url_version_prefix(auth_url): """Fix up the auth url if an invalid or no version prefix was given. Fix the URL to say v3 in this case and add version if it is missing entirely. This should be smarter and use discovery. Until version discovery is implemented we need this method to get e...
[ "def", "fix_auth_url_version_prefix", "(", "auth_url", ")", ":", "auth_url", "=", "_augment_url_with_version", "(", "auth_url", ")", "url_fixed", "=", "False", "if", "has_in_url_path", "(", "auth_url", ",", "[", "\"/v2.0\"", "]", ")", ":", "url_fixed", "=", "Tru...
[ 298, 0 ]
[ 313, 30 ]
python
en
['en', 'en', 'en']
True
clean_up_auth_url
(auth_url)
Clean up the auth url to extract the exact Keystone URL
Clean up the auth url to extract the exact Keystone URL
def clean_up_auth_url(auth_url): """Clean up the auth url to extract the exact Keystone URL""" # NOTE(mnaser): This drops the query and fragment because we're only # trying to extract the Keystone URL. scheme, netloc, path, query, fragment = urlparse.urlsplit(auth_url) return urlparse...
[ "def", "clean_up_auth_url", "(", "auth_url", ")", ":", "# NOTE(mnaser): This drops the query and fragment because we're only", "# trying to extract the Keystone URL.", "scheme", ",", "netloc", ",", "path", ",", "query", ",", "fragment", "=", "urlparse", ".", "ur...
[ 316, 0 ]
[ 323, 62 ]
python
en
['en', 'en', 'en']
True
default_services_region
(service_catalog, request=None, ks_endpoint=None)
Return the default service region. Order of precedence: 1. 'services_region' cookie value 2. Matching endpoint in DEFAULT_SERVICE_REGIONS 3. '*' key in DEFAULT_SERVICE_REGIONS 4. First valid region from catalog In each case the value must also be present in available_regions or we move to ...
Return the default service region.
def default_services_region(service_catalog, request=None, ks_endpoint=None): """Return the default service region. Order of precedence: 1. 'services_region' cookie value 2. Matching endpoint in DEFAULT_SERVICE_REGIONS 3. '*' key in DEFAULT_SERVICE_REGIONS 4. First v...
[ "def", "default_services_region", "(", "service_catalog", ",", "request", "=", "None", ",", "ks_endpoint", "=", "None", ")", ":", "if", "service_catalog", ":", "available_regions", "=", "[", "get_endpoint_region", "(", "endpoint", ")", "for", "service", "in", "s...
[ 370, 0 ]
[ 414, 15 ]
python
en
['en', 'de', 'en']
True
set_response_cookie
(response, cookie_name, cookie_value)
Common function for setting the cookie in the response. Provides a common policy of setting cookies for last used project and region, can be reused in other locations. This method will set the cookie to expire in 365 days.
Common function for setting the cookie in the response.
def set_response_cookie(response, cookie_name, cookie_value): """Common function for setting the cookie in the response. Provides a common policy of setting cookies for last used project and region, can be reused in other locations. This method will set the cookie to expire in 365 days. """ no...
[ "def", "set_response_cookie", "(", "response", ",", "cookie_name", ",", "cookie_value", ")", ":", "now", "=", "timezone", ".", "now", "(", ")", "expire_date", "=", "now", "+", "datetime", ".", "timedelta", "(", "days", "=", "365", ")", "response", ".", "...
[ 417, 0 ]
[ 427, 71 ]
python
en
['en', 'en', 'en']
True
get_endpoint_region
(endpoint)
Common function for getting the region from endpoint. In Keystone V3, region has been deprecated in favor of region_id. This method provides a way to get region that works for both Keystone V2 and V3.
Common function for getting the region from endpoint.
def get_endpoint_region(endpoint): """Common function for getting the region from endpoint. In Keystone V3, region has been deprecated in favor of region_id. This method provides a way to get region that works for both Keystone V2 and V3. """ return endpoint.get('region_id') or endpoint.ge...
[ "def", "get_endpoint_region", "(", "endpoint", ")", ":", "return", "endpoint", ".", "get", "(", "'region_id'", ")", "or", "endpoint", ".", "get", "(", "'region'", ")" ]
[ 430, 0 ]
[ 439, 62 ]
python
en
['en', 'en', 'en']
True
get_admin_roles
()
Common function for getting the admin roles from settings :return: Set object including all admin roles. If there is no role, this will return empty:: { "foo", "bar", "admin" }
Common function for getting the admin roles from settings
def get_admin_roles(): """Common function for getting the admin roles from settings :return: Set object including all admin roles. If there is no role, this will return empty:: { "foo", "bar", "admin" } """ admin_roles = {role.lower() for role ...
[ "def", "get_admin_roles", "(", ")", ":", "admin_roles", "=", "{", "role", ".", "lower", "(", ")", "for", "role", "in", "settings", ".", "OPENSTACK_KEYSTONE_ADMIN_ROLES", "}", "return", "admin_roles" ]
[ 447, 0 ]
[ 461, 22 ]
python
en
['en', 'en', 'en']
True
get_role_permission
(role)
Common function for getting the permission froms arg This format is 'openstack.roles.xxx' and 'xxx' is a real role name. :returns: String like "openstack.roles.admin" If role is None, this will return None.
Common function for getting the permission froms arg
def get_role_permission(role): """Common function for getting the permission froms arg This format is 'openstack.roles.xxx' and 'xxx' is a real role name. :returns: String like "openstack.roles.admin" If role is None, this will return None. """ return "openstack.roles.%s" % role.l...
[ "def", "get_role_permission", "(", "role", ")", ":", "return", "\"openstack.roles.%s\"", "%", "role", ".", "lower", "(", ")" ]
[ 464, 0 ]
[ 474, 46 ]
python
en
['en', 'en', 'en']
True
get_admin_permissions
()
Common function for getting the admin permissions from settings This format is 'openstack.roles.xxx' and 'xxx' is a real role name. :returns: Set object including all admin permission. If there is no permission, this will return empty:: { "openstack.roles.foo", "...
Common function for getting the admin permissions from settings
def get_admin_permissions(): """Common function for getting the admin permissions from settings This format is 'openstack.roles.xxx' and 'xxx' is a real role name. :returns: Set object including all admin permission. If there is no permission, this will return empty:: { ...
[ "def", "get_admin_permissions", "(", ")", ":", "return", "{", "get_role_permission", "(", "role", ")", "for", "role", "in", "get_admin_roles", "(", ")", "}" ]
[ 477, 0 ]
[ 493, 68 ]
python
en
['en', 'en', 'en']
True
get_client_ip
(request)
Return client ip address using SECURE_PROXY_ADDR_HEADER variable. If not present or not defined on settings then REMOTE_ADDR is used. :param request: Django http request object. :type request: django.http.HttpRequest :returns: Possible client ip address :rtype: string
Return client ip address using SECURE_PROXY_ADDR_HEADER variable.
def get_client_ip(request): """Return client ip address using SECURE_PROXY_ADDR_HEADER variable. If not present or not defined on settings then REMOTE_ADDR is used. :param request: Django http request object. :type request: django.http.HttpRequest :returns: Possible client ip address :rtype: ...
[ "def", "get_client_ip", "(", "request", ")", ":", "_SECURE_PROXY_ADDR_HEADER", "=", "settings", ".", "SECURE_PROXY_ADDR_HEADER", "if", "_SECURE_PROXY_ADDR_HEADER", ":", "return", "request", ".", "META", ".", "get", "(", "_SECURE_PROXY_ADDR_HEADER", ",", "request", "."...
[ 496, 0 ]
[ 513, 42 ]
python
en
['en', 'en', 'en']
True
store_initial_k2k_session
(auth_url, request, scoped_auth_ref, unscoped_auth_ref)
Stores session variables if there are k2k service providers This stores variables related to Keystone2Keystone federation. This function gets skipped if there are no Keystone service providers. An unscoped token to the identity provider keystone gets stored so that it can be used to do federated login ...
Stores session variables if there are k2k service providers
def store_initial_k2k_session(auth_url, request, scoped_auth_ref, unscoped_auth_ref): """Stores session variables if there are k2k service providers This stores variables related to Keystone2Keystone federation. This function gets skipped if there are no Keystone service provi...
[ "def", "store_initial_k2k_session", "(", "auth_url", ",", "request", ",", "scoped_auth_ref", ",", "unscoped_auth_ref", ")", ":", "keystone_provider_id", "=", "request", ".", "session", ".", "get", "(", "'keystone_provider_id'", ",", "None", ")", "if", "keystone_prov...
[ 516, 0 ]
[ 562, 50 ]
python
en
['en', 'en', 'en']
True
build_local
(context)
build an image from a Dockerfile with tag 'latest-dev'
build an image from a Dockerfile with tag 'latest-dev'
def build_local(context): """ build an image from a Dockerfile with tag 'latest-dev' """ context.run(f"docker build -t {IMAGE_NAME}:latest-dev . -f Dockerfile")
[ "def", "build_local", "(", "context", ")", ":", "context", ".", "run", "(", "f\"docker build -t {IMAGE_NAME}:latest-dev . -f Dockerfile\"", ")" ]
[ 8, 0 ]
[ 12, 75 ]
python
en
['en', 'error', 'th']
False
run
(context)
run the local image with tag 'latest-dev'
run the local image with tag 'latest-dev'
def run(context): """ run the local image with tag 'latest-dev' """ context.run(f"docker run --rm --name {CONTAINER_NAME}-{CONTAINER_INSTANCE} -p 8888:8888 {IMAGE_NAME}:latest-dev")
[ "def", "run", "(", "context", ")", ":", "context", ".", "run", "(", "f\"docker run --rm --name {CONTAINER_NAME}-{CONTAINER_INSTANCE} -p 8888:8888 {IMAGE_NAME}:latest-dev\"", ")" ]
[ 15, 0 ]
[ 19, 117 ]
python
en
['en', 'error', 'th']
False
docker_clean
(context, images=False)
remove containers, networks, volumes and images(optional)
remove containers, networks, volumes and images(optional)
def docker_clean(context, images=False): """ remove containers, networks, volumes and images(optional) """ context.run("docker compose down -v") if images: # delete project image context.run(f"docker rmi {IMAGE_NAME}:latest-dev -f") # remove dangling images conte...
[ "def", "docker_clean", "(", "context", ",", "images", "=", "False", ")", ":", "context", ".", "run", "(", "\"docker compose down -v\"", ")", "if", "images", ":", "# delete project image", "context", ".", "run", "(", "f\"docker rmi {IMAGE_NAME}:latest-dev -f\"", ")",...
[ 25, 0 ]
[ 35, 45 ]
python
en
['en', 'error', 'th']
False
differential_to_unicycle
(left_motor_velocity: Real, right_motor_velocity: Real)
Convert differential steering commands into unicycle steering commands. :param left_motor_velocity: [cm / s] :param right_motor_velocity: [cm / s] :return: A tuple containing (linear_velocity [cm / s], angular_velocity [deg / s])
Convert differential steering commands into unicycle steering commands.
def differential_to_unicycle(left_motor_velocity: Real, right_motor_velocity: Real) -> Tuple[Real, Real]: """ Convert differential steering commands into unicycle steering commands. :param left_motor_velocity: [cm / s] :param right_motor_velocity: [cm / s] :return: A tuple containing (linear_veloci...
[ "def", "differential_to_unicycle", "(", "left_motor_velocity", ":", "Real", ",", "right_motor_velocity", ":", "Real", ")", "->", "Tuple", "[", "Real", ",", "Real", "]", ":", "linear_velocity", "=", "(", "left_motor_velocity", "+", "right_motor_velocity", ")", "/",...
[ 244, 0 ]
[ 256, 44 ]
python
en
['en', 'error', 'th']
False
unicycle_to_differential
(linear_velocity: Real, angular_velocity: Real)
Convert unicycle steering commands into differential steering commands. :param linear_velocity: How fast the robot should travel [cm / s] :param angular_velocity: How fast the robot should rotate [deg / s] :return: A tuple containing (left_motor_velocity, right_motor_velocity) [cm / s]
Convert unicycle steering commands into differential steering commands.
def unicycle_to_differential(linear_velocity: Real, angular_velocity: Real) -> Tuple[Real, Real]: """ Convert unicycle steering commands into differential steering commands. :param linear_velocity: How fast the robot should travel [cm / s] :param angular_velocity: How fast the robot should rotate [deg ...
[ "def", "unicycle_to_differential", "(", "linear_velocity", ":", "Real", ",", "angular_velocity", ":", "Real", ")", "->", "Tuple", "[", "Real", ",", "Real", "]", ":", "# Convert angular velocity from [deg / s] of the body to [cm / s] of the wheel", "angular_velocity", "=", ...
[ 259, 0 ]
[ 274, 52 ]
python
en
['en', 'error', 'th']
False
ticks_to_distance
(ticks: int)
Convert encoder ticks into distance [cm]. :param ticks: Number of encoder ticks. :return: Distance that number of ticks represents [cm].
Convert encoder ticks into distance [cm].
def ticks_to_distance(ticks: int) -> Real: """ Convert encoder ticks into distance [cm]. :param ticks: Number of encoder ticks. :return: Distance that number of ticks represents [cm]. """ return ticks * WHEEL_CM_PER_TICK
[ "def", "ticks_to_distance", "(", "ticks", ":", "int", ")", "->", "Real", ":", "return", "ticks", "*", "WHEEL_CM_PER_TICK" ]
[ 277, 0 ]
[ 285, 36 ]
python
en
['en', 'error', 'th']
False
distance_to_ticks
(distance: Real)
Convert distance [cm] into encoder ticks. :param distance: [cm] :return: Number of encoder ticks (rounded) that distance represents.
Convert distance [cm] into encoder ticks.
def distance_to_ticks(distance: Real) -> int: """ Convert distance [cm] into encoder ticks. :param distance: [cm] :return: Number of encoder ticks (rounded) that distance represents. """ return int(round(distance * WHEEL_TICK_PER_CM))
[ "def", "distance_to_ticks", "(", "distance", ":", "Real", ")", "->", "int", ":", "return", "int", "(", "round", "(", "distance", "*", "WHEEL_TICK_PER_CM", ")", ")" ]
[ 288, 0 ]
[ 296, 51 ]
python
en
['en', 'error', 'th']
False
DriveMotorController.set_acceleration
(self, acceleration: int = 8000)
Sets the controller acceleration. :param acceleration: How quickly the controller should accelerate to a new velocity [ticks / s^2]. If set to 0, acceleration is instant.
Sets the controller acceleration.
def set_acceleration(self, acceleration: int = 8000) -> None: """ Sets the controller acceleration. :param acceleration: How quickly the controller should accelerate to a new velocity [ticks / s^2]. If set to 0, acceleration is instant. """ if acceleration < 0: ...
[ "def", "set_acceleration", "(", "self", ",", "acceleration", ":", "int", "=", "8000", ")", "->", "None", ":", "if", "acceleration", "<", "0", ":", "raise", "ValueError", "(", "f'Acceleration must be >= 0. Given acceleration: {acceleration}'", ")", "# Send the bytes fo...
[ 103, 4 ]
[ 116, 98 ]
python
en
['en', 'error', 'th']
False
DriveMotorController.set_pid_tunings
(self, p: float = 0.05, i: float = 0.5, d: float = 0.0)
Good default tunings: ``(0.05, 0.5, 0)``
Good default tunings: ``(0.05, 0.5, 0)``
def set_pid_tunings(self, p: float = 0.05, i: float = 0.5, d: float = 0.0) -> None: """ Good default tunings: ``(0.05, 0.5, 0)`` """ # Make sure tunings are non-negative if p < 0 or i < 0 or d < 0: raise ValueError(f'All tunings must be non-negative. Given tunings: p...
[ "def", "set_pid_tunings", "(", "self", ",", "p", ":", "float", "=", "0.05", ",", "i", ":", "float", "=", "0.5", ",", "d", ":", "float", "=", "0.0", ")", "->", "None", ":", "# Make sure tunings are non-negative", "if", "p", "<", "0", "or", "i", "<", ...
[ 122, 4 ]
[ 132, 106 ]
python
en
['en', 'error', 'th']
False
DriveMotorController.set_velocity_unicycle
(self, linear_velocity: Real, angular_velocity: Real)
:param linear_velocity: How fast the robot should travel [cm / s] :param angular_velocity: How fast the robot should rotate [deg / s]
:param linear_velocity: How fast the robot should travel [cm / s] :param angular_velocity: How fast the robot should rotate [deg / s]
def set_velocity_unicycle(self, linear_velocity: Real, angular_velocity: Real) -> DriveMotorState: """ :param linear_velocity: How fast the robot should travel [cm / s] :param angular_velocity: How fast the robot should rotate [deg / s] """ return self.set_velocity_differential(...
[ "def", "set_velocity_unicycle", "(", "self", ",", "linear_velocity", ":", "Real", ",", "angular_velocity", ":", "Real", ")", "->", "DriveMotorState", ":", "return", "self", ".", "set_velocity_differential", "(", "*", "unicycle_to_differential", "(", "linear_velocity",...
[ 155, 4 ]
[ 164, 9 ]
python
en
['en', 'error', 'th']
False
DriveMotorController._send_command
(self, data: bytes)
Sends the command data, receives a response packet, makes sure the 0th byte of the response is an ACK (i.e. that it matches the 0th byte of the data, which is the command byte), and then returns the part of the response that comes after the ACK (0th) byte. :param data: The command data ...
Sends the command data, receives a response packet, makes sure the 0th byte of the response is an ACK (i.e. that it matches the 0th byte of the data, which is the command byte), and then returns the part of the response that comes after the ACK (0th) byte. :param data: The command data ...
def _send_command(self, data: bytes) -> bytes: """ Sends the command data, receives a response packet, makes sure the 0th byte of the response is an ACK (i.e. that it matches the 0th byte of the data, which is the command byte), and then returns the part of the response that comes after ...
[ "def", "_send_command", "(", "self", ",", "data", ":", "bytes", ")", "->", "bytes", ":", "if", "not", "data", ":", "raise", "ValueError", "(", "'data must be given'", ")", "response", "=", "self", ".", "_packets", ".", "write_then_read", "(", "data", ")", ...
[ 169, 4 ]
[ 196, 27 ]
python
en
['en', 'error', 'th']
False
build_narrow_filter
(narrow: Collection[Sequence[str]])
Changes to this function should come with corresponding changes to BuildNarrowFilterTest.
Changes to this function should come with corresponding changes to BuildNarrowFilterTest.
def build_narrow_filter(narrow: Collection[Sequence[str]]) -> Callable[[Mapping[str, Any]], bool]: """Changes to this function should come with corresponding changes to BuildNarrowFilterTest.""" check_supported_events_narrow_filter(narrow) def narrow_filter(event: Mapping[str, Any]) -> bool: me...
[ "def", "build_narrow_filter", "(", "narrow", ":", "Collection", "[", "Sequence", "[", "str", "]", "]", ")", "->", "Callable", "[", "[", "Mapping", "[", "str", ",", "Any", "]", "]", ",", "bool", "]", ":", "check_supported_events_narrow_filter", "(", "narrow...
[ 58, 0 ]
[ 98, 24 ]
python
en
['en', 'en', 'en']
True
test_change_level_undo
(testdir)
Ensure that 'set_level' is undone after the end of the test
Ensure that 'set_level' is undone after the end of the test
def test_change_level_undo(testdir): """Ensure that 'set_level' is undone after the end of the test""" testdir.makepyfile(''' import logging def test1(caplog): caplog.set_level(logging.INFO) # using + operator here so fnmatch_lines doesn't match the code in the traceback...
[ "def", "test_change_level_undo", "(", "testdir", ")", ":", "testdir", ".", "makepyfile", "(", "'''\n import logging\n\n def test1(caplog):\n caplog.set_level(logging.INFO)\n # using + operator here so fnmatch_lines doesn't match the code in the traceback\n ...
[ 29, 0 ]
[ 50, 54 ]
python
en
['en', 'en', 'en']
True
build_topic_mute_checker
( cursor: CursorObj, user_profile: UserProfile )
This function is similar to the function of the same name in zerver/lib/topic_mutes.py, but it works without the ORM, so that we can use it in migrations.
This function is similar to the function of the same name in zerver/lib/topic_mutes.py, but it works without the ORM, so that we can use it in migrations.
def build_topic_mute_checker( cursor: CursorObj, user_profile: UserProfile ) -> Callable[[int, str], bool]: """ This function is similar to the function of the same name in zerver/lib/topic_mutes.py, but it works without the ORM, so that we can use it in migrations. """ query = SQL( ...
[ "def", "build_topic_mute_checker", "(", "cursor", ":", "CursorObj", ",", "user_profile", ":", "UserProfile", ")", "->", "Callable", "[", "[", "int", ",", "str", "]", ",", "bool", "]", ":", "query", "=", "SQL", "(", "\"\"\"\n SELECT\n recipient_...
[ 24, 0 ]
[ 51, 19 ]
python
en
['en', 'error', 'th']
False
PasswordForm.clean
(self)
Check to make sure password fields match.
Check to make sure password fields match.
def clean(self): '''Check to make sure password fields match.''' data = super(PasswordForm, self).clean() if 'new_password' in data: if data['new_password'] != data.get('confirm_password', None): raise ValidationError(_('Passwords do not match.')) if data....
[ "def", "clean", "(", "self", ")", ":", "data", "=", "super", "(", "PasswordForm", ",", "self", ")", ".", "clean", "(", ")", "if", "'new_password'", "in", "data", ":", "if", "data", "[", "'new_password'", "]", "!=", "data", ".", "get", "(", "'confirm_...
[ 44, 4 ]
[ 54, 19 ]
python
en
['en', 'en', 'en']
True
main
()
Script entry point.
Script entry point.
def main(): """Script entry point.""" register_custom_components() cfg = custom_parse_args(evaluation=True) status = enjoy(cfg) return status
[ "def", "main", "(", ")", ":", "register_custom_components", "(", ")", "cfg", "=", "custom_parse_args", "(", "evaluation", "=", "True", ")", "status", "=", "enjoy", "(", "cfg", ")", "return", "status" ]
[ 6, 0 ]
[ 11, 17 ]
python
en
['en', 'en', 'en']
True
VolumeTypesFilterAction.filter
(self, table, volume_types, filter_string)
Naive case-insensitive search.
Naive case-insensitive search.
def filter(self, table, volume_types, filter_string): """Naive case-insensitive search.""" query = filter_string.lower() return [volume_type for volume_type in volume_types if query in volume_type.name.lower()]
[ "def", "filter", "(", "self", ",", "table", ",", "volume_types", ",", "filter_string", ")", ":", "query", "=", "filter_string", ".", "lower", "(", ")", "return", "[", "volume_type", "for", "volume_type", "in", "volume_types", "if", "query", "in", "volume_typ...
[ 184, 4 ]
[ 188, 53 ]
python
en
['en', 'it', 'en']
True
TypedContent.qref
(self)
Get the I{type} qualified reference to the referenced xsd type. This method takes into account simple types defined through restriction with are detected by determining that self is simple (len=0) and by finding a restriction child. @return: The I{type} qualified reference. ...
Get the I{type} qualified reference to the referenced xsd type. This method takes into account simple types defined through restriction with are detected by determining that self is simple (len=0) and by finding a restriction child.
def qref(self): """ Get the I{type} qualified reference to the referenced xsd type. This method takes into account simple types defined through restriction with are detected by determining that self is simple (len=0) and by finding a restriction child. @return: The I{type...
[ "def", "qref", "(", "self", ")", ":", "qref", "=", "self", ".", "type", "if", "qref", "is", "None", "and", "len", "(", "self", ")", "==", "0", ":", "ls", "=", "[", "]", "m", "=", "RestrictionMatcher", "(", ")", "finder", "=", "NodeFinder", "(", ...
[ 73, 4 ]
[ 90, 19 ]
python
en
['en', 'error', 'th']
False
Element.implany
(self)
Set the type as any when implicit. An implicit <xs:any/> is when an element has not body and no type defined. @return: self @rtype: L{Element}
Set the type as any when implicit. An implicit <xs:any/> is when an element has not body and no type defined.
def implany(self): """ Set the type as any when implicit. An implicit <xs:any/> is when an element has not body and no type defined. @return: self @rtype: L{Element} """ if self.type is None and \ self.ref is None and \ self.root.is...
[ "def", "implany", "(", "self", ")", ":", "if", "self", ".", "type", "is", "None", "and", "self", ".", "ref", "is", "None", "and", "self", ".", "root", ".", "isempty", "(", ")", ":", "self", ".", "type", "=", "self", ".", "anytype", "(", ")", "r...
[ 384, 4 ]
[ 396, 19 ]
python
en
['en', 'error', 'th']
False
Element.anytype
(self)
create an xsd:anyType reference
create an xsd:anyType reference
def anytype(self): """ create an xsd:anyType reference """ p,u = Namespace.xsdns mp = self.root.findPrefix(u) if mp is None: mp = p self.root.addPrefix(p, u) return ':'.join((mp, 'anyType'))
[ "def", "anytype", "(", "self", ")", ":", "p", ",", "u", "=", "Namespace", ".", "xsdns", "mp", "=", "self", ".", "root", ".", "findPrefix", "(", "u", ")", "if", "mp", "is", "None", ":", "mp", "=", "p", "self", ".", "root", ".", "addPrefix", "(",...
[ 433, 4 ]
[ 440, 40 ]
python
en
['en', 'en', 'en']
True
Import.bind
(cls, ns, location=None)
Bind a namespace to a schema location (URI). This is used for imports that don't specify a schemaLocation. @param ns: A namespace-uri. @type ns: str @param location: The (optional) schema location for the namespace. (default=ns). @type location: str ...
Bind a namespace to a schema location (URI). This is used for imports that don't specify a schemaLocation.
def bind(cls, ns, location=None): """ Bind a namespace to a schema location (URI). This is used for imports that don't specify a schemaLocation. @param ns: A namespace-uri. @type ns: str @param location: The (optional) schema location for the namespace. (de...
[ "def", "bind", "(", "cls", ",", "ns", ",", "location", "=", "None", ")", ":", "if", "location", "is", "None", ":", "location", "=", "ns", "cls", ".", "locations", "[", "ns", "]", "=", "location" ]
[ 502, 4 ]
[ 514, 36 ]
python
en
['en', 'error', 'th']
False
Import.open
(self, options)
Open and import the refrenced schema. @param options: An options dictionary. @type options: L{options.Options} @return: The referenced schema. @rtype: L{Schema}
Open and import the refrenced schema.
def open(self, options): """ Open and import the refrenced schema. @param options: An options dictionary. @type options: L{options.Options} @return: The referenced schema. @rtype: L{Schema} """ if self.opened: return self.opened = True ...
[ "def", "open", "(", "self", ",", "options", ")", ":", "if", "self", ".", "opened", ":", "return", "self", ".", "opened", "=", "True", "log", ".", "debug", "(", "'%s, importing ns=\"%s\", location=\"%s\"'", ",", "self", ".", "id", ",", "self", ".", "ns", ...
[ 524, 4 ]
[ 543, 21 ]
python
en
['en', 'error', 'th']
False
Import.locate
(self)
find the schema locally
find the schema locally
def locate(self): """ find the schema locally """ if self.ns[1] == self.schema.tns[1]: return None else: return self.schema.locate(self.ns)
[ "def", "locate", "(", "self", ")", ":", "if", "self", ".", "ns", "[", "1", "]", "==", "self", ".", "schema", ".", "tns", "[", "1", "]", ":", "return", "None", "else", ":", "return", "self", ".", "schema", ".", "locate", "(", "self", ".", "ns", ...
[ 545, 4 ]
[ 550, 46 ]
python
en
['en', 'de', 'en']
True
Import.download
(self, options)
download the schema
download the schema
def download(self, options): """ download the schema """ url = self.location try: if '://' not in url: url = urljoin(self.schema.baseurl, url) reader = DocumentReader(options) d = reader.open(url) root = d.root() root.se...
[ "def", "download", "(", "self", ",", "options", ")", ":", "url", "=", "self", ".", "location", "try", ":", "if", "'://'", "not", "in", "url", ":", "url", "=", "urljoin", "(", "self", ".", "schema", ".", "baseurl", ",", "url", ")", "reader", "=", ...
[ 552, 4 ]
[ 566, 32 ]
python
en
['en', 'de', 'en']
True
Include.open
(self, options)
Open and include the refrenced schema. @param options: An options dictionary. @type options: L{options.Options} @return: The referenced schema. @rtype: L{Schema}
Open and include the refrenced schema.
def open(self, options): """ Open and include the refrenced schema. @param options: An options dictionary. @type options: L{options.Options} @return: The referenced schema. @rtype: L{Schema} """ if self.opened: return self.opened = True...
[ "def", "open", "(", "self", ",", "options", ")", ":", "if", "self", ".", "opened", ":", "return", "self", ".", "opened", "=", "True", "log", ".", "debug", "(", "'%s, including location=\"%s\"'", ",", "self", ".", "id", ",", "self", ".", "location", ")"...
[ 590, 4 ]
[ 604, 21 ]
python
en
['en', 'error', 'th']
False
Include.download
(self, options)
download the schema
download the schema
def download(self, options): """ download the schema """ url = self.location try: if '://' not in url: url = urljoin(self.schema.baseurl, url) reader = DocumentReader(options) d = reader.open(url) root = d.root() root.se...
[ "def", "download", "(", "self", ",", "options", ")", ":", "url", "=", "self", ".", "location", "try", ":", "if", "'://'", "not", "in", "url", ":", "url", "=", "urljoin", "(", "self", ".", "schema", ".", "baseurl", ",", "url", ")", "reader", "=", ...
[ 606, 4 ]
[ 621, 32 ]
python
en
['en', 'de', 'en']
True
Include.__applytns
(self, root)
make sure included schema has same tns.
make sure included schema has same tns.
def __applytns(self, root): """ make sure included schema has same tns. """ TNS = 'targetNamespace' tns = root.get(TNS) if tns is None: tns = self.schema.tns[1] root.set(TNS, tns) else: if self.schema.tns[1] != tns: raise Except...
[ "def", "__applytns", "(", "self", ",", "root", ")", ":", "TNS", "=", "'targetNamespace'", "tns", "=", "root", ".", "get", "(", "TNS", ")", "if", "tns", "is", "None", ":", "tns", "=", "self", ".", "schema", ".", "tns", "[", "1", "]", "root", ".", ...
[ 623, 4 ]
[ 632, 52 ]
python
en
['en', 'en', 'en']
True
Attribute.get_default
(self)
Gets the <xs:attribute default=""/> attribute value. @return: The default value for the attribute @rtype: str
Gets the <xs:attribute default=""/> attribute value.
def get_default(self): """ Gets the <xs:attribute default=""/> attribute value. @return: The default value for the attribute @rtype: str """ return self.root.get('default', default='')
[ "def", "get_default", "(", "self", ")", ":", "return", "self", ".", "root", ".", "get", "(", "'default'", ",", "default", "=", "''", ")" ]
[ 654, 4 ]
[ 660, 51 ]
python
en
['en', 'error', 'th']
False
Factory.maptag
(cls, tag, fn)
Map (override) tag => I{class} mapping. @param tag: An xsd tag name. @type tag: str @param fn: A function or class. @type fn: fn|class.
Map (override) tag => I{class} mapping.
def maptag(cls, tag, fn): """ Map (override) tag => I{class} mapping. @param tag: An xsd tag name. @type tag: str @param fn: A function or class. @type fn: fn|class. """ cls.tags[tag] = fn
[ "def", "maptag", "(", "cls", ",", "tag", ",", "fn", ")", ":", "cls", ".", "tags", "[", "tag", "]", "=", "fn" ]
[ 732, 4 ]
[ 740, 26 ]
python
en
['en', 'error', 'th']
False
Factory.create
(cls, root, schema)
Create an object based on the root tag name. @param root: An XML root element. @type root: L{Element} @param schema: A schema object. @type schema: L{schema.Schema} @return: The created object. @rtype: L{SchemaObject}
Create an object based on the root tag name.
def create(cls, root, schema): """ Create an object based on the root tag name. @param root: An XML root element. @type root: L{Element} @param schema: A schema object. @type schema: L{schema.Schema} @return: The created object. @rtype: L{SchemaObject} ...
[ "def", "create", "(", "cls", ",", "root", ",", "schema", ")", ":", "fn", "=", "cls", ".", "tags", ".", "get", "(", "root", ".", "name", ")", "if", "fn", "is", "not", "None", ":", "return", "fn", "(", "schema", ",", "root", ")", "else", ":", "...
[ 743, 4 ]
[ 757, 23 ]
python
en
['en', 'error', 'th']
False
Factory.build
(cls, root, schema, filter=('*',))
Build an xsobject representation. @param root: An schema XML root. @type root: L{sax.element.Element} @param filter: A tag filter. @type filter: [str,...] @return: A schema object graph. @rtype: L{sxbase.SchemaObject}
Build an xsobject representation.
def build(cls, root, schema, filter=('*',)): """ Build an xsobject representation. @param root: An schema XML root. @type root: L{sax.element.Element} @param filter: A tag filter. @type filter: [str,...] @return: A schema object graph. @rtype: L{sxbase.Sch...
[ "def", "build", "(", "cls", ",", "root", ",", "schema", ",", "filter", "=", "(", "'*'", ",", ")", ")", ":", "children", "=", "[", "]", "for", "node", "in", "root", ".", "getChildren", "(", "ns", "=", "Namespace", ".", "xsdns", ")", ":", "if", "...
[ 760, 4 ]
[ 779, 23 ]
python
en
['en', 'error', 'th']
False
upload_docs._build_multipart
(cls, data)
Build up the MIME payload for the POST data
Build up the MIME payload for the POST data
def _build_multipart(cls, data): """ Build up the MIME payload for the POST data """ boundary = '--------------GHSKFJDLGDS7543FJKLFHRE75642756743254' sep_boundary = b'\n--' + boundary.encode('ascii') end_boundary = sep_boundary + b'--' end_items = end_boundary, b"...
[ "def", "_build_multipart", "(", "cls", ",", "data", ")", ":", "boundary", "=", "'--------------GHSKFJDLGDS7543FJKLFHRE75642756743254'", "sep_boundary", "=", "b'\\n--'", "+", "boundary", ".", "encode", "(", "'ascii'", ")", "end_boundary", "=", "sep_boundary", "+", "b...
[ 123, 4 ]
[ 139, 49 ]
python
en
['en', 'error', 'th']
False
SchemaObject.prepend
(cls, d, s, filter=Filter())
Prepend schema object's from B{s}ource list to the B{d}estination list while applying the filter. @param d: The destination list. @type d: list @param s: The source list. @type s: list @param filter: A filter that allows items to be prepended. @type filt...
Prepend schema object's from B{s}ource list to the B{d}estination list while applying the filter.
def prepend(cls, d, s, filter=Filter()): """ Prepend schema object's from B{s}ource list to the B{d}estination list while applying the filter. @param d: The destination list. @type d: list @param s: The source list. @type s: list @param filter: A filter t...
[ "def", "prepend", "(", "cls", ",", "d", ",", "s", ",", "filter", "=", "Filter", "(", ")", ")", ":", "i", "=", "0", "for", "x", "in", "s", ":", "if", "x", "in", "filter", ":", "d", ".", "insert", "(", "i", ",", "x", ")", "i", "+=", "1" ]
[ 51, 4 ]
[ 66, 22 ]
python
en
['en', 'error', 'th']
False
SchemaObject.append
(cls, d, s, filter=Filter())
Append schema object's from B{s}ource list to the B{d}estination list while applying the filter. @param d: The destination list. @type d: list @param s: The source list. @type s: list @param filter: A filter that allows items to be appended. @type filter...
Append schema object's from B{s}ource list to the B{d}estination list while applying the filter.
def append(cls, d, s, filter=Filter()): """ Append schema object's from B{s}ource list to the B{d}estination list while applying the filter. @param d: The destination list. @type d: list @param s: The source list. @type s: list @param filter: A filter tha...
[ "def", "append", "(", "cls", ",", "d", ",", "s", ",", "filter", "=", "Filter", "(", ")", ")", ":", "for", "item", "in", "s", ":", "if", "item", "in", "filter", ":", "d", ".", "append", "(", "item", ")" ]
[ 69, 4 ]
[ 82, 30 ]
python
en
['en', 'error', 'th']
False
SchemaObject.__init__
(self, schema, root)
@param schema: The containing schema. @type schema: L{schema.Schema} @param root: The xml root node. @type root: L{Element}
def __init__(self, schema, root): """ @param schema: The containing schema. @type schema: L{schema.Schema} @param root: The xml root node. @type root: L{Element} """ self.schema = schema self.root = root self.id = objid(self) self.name = ro...
[ "def", "__init__", "(", "self", ",", "schema", ",", "root", ")", ":", "self", ".", "schema", "=", "schema", "self", ".", "root", "=", "root", "self", ".", "id", "=", "objid", "(", "self", ")", "self", ".", "name", "=", "root", ".", "get", "(", ...
[ 84, 4 ]
[ 104, 23 ]
python
en
['en', 'error', 'th']
False
SchemaObject.attributes
(self, filter=Filter())
Get only the attribute content. @param filter: A filter to constrain the result. @type filter: L{Filter} @return: A list of tuples (attr, ancestry) @rtype: [(L{SchemaObject}, [L{SchemaObject},..]),..]
Get only the attribute content.
def attributes(self, filter=Filter()): """ Get only the attribute content. @param filter: A filter to constrain the result. @type filter: L{Filter} @return: A list of tuples (attr, ancestry) @rtype: [(L{SchemaObject}, [L{SchemaObject},..]),..] """ result =...
[ "def", "attributes", "(", "self", ",", "filter", "=", "Filter", "(", ")", ")", ":", "result", "=", "[", "]", "for", "child", ",", "ancestry", "in", "self", ":", "if", "child", ".", "isattr", "(", ")", "and", "child", "in", "filter", ":", "result", ...
[ 106, 4 ]
[ 118, 21 ]
python
en
['en', 'error', 'th']
False
SchemaObject.children
(self, filter=Filter())
Get only the I{direct} or non-attribute content. @param filter: A filter to constrain the result. @type filter: L{Filter} @return: A list tuples: (child, ancestry) @rtype: [(L{SchemaObject}, [L{SchemaObject},..]),..]
Get only the I{direct} or non-attribute content.
def children(self, filter=Filter()): """ Get only the I{direct} or non-attribute content. @param filter: A filter to constrain the result. @type filter: L{Filter} @return: A list tuples: (child, ancestry) @rtype: [(L{SchemaObject}, [L{SchemaObject},..]),..] """ ...
[ "def", "children", "(", "self", ",", "filter", "=", "Filter", "(", ")", ")", ":", "result", "=", "[", "]", "for", "child", ",", "ancestry", "in", "self", ":", "if", "not", "child", ".", "isattr", "(", ")", "and", "child", "in", "filter", ":", "re...
[ 120, 4 ]
[ 132, 21 ]
python
en
['en', 'error', 'th']
False
SchemaObject.get_attribute
(self, name)
Get (find) a I{non-attribute} attribute by name. @param name: A attribute name. @type name: str @return: A tuple: the requested (attribute, ancestry). @rtype: (L{SchemaObject}, [L{SchemaObject},..])
Get (find) a I{non-attribute} attribute by name.
def get_attribute(self, name): """ Get (find) a I{non-attribute} attribute by name. @param name: A attribute name. @type name: str @return: A tuple: the requested (attribute, ancestry). @rtype: (L{SchemaObject}, [L{SchemaObject},..]) """ for child, ancestr...
[ "def", "get_attribute", "(", "self", ",", "name", ")", ":", "for", "child", ",", "ancestry", "in", "self", ".", "attributes", "(", ")", ":", "if", "child", ".", "name", "==", "name", ":", "return", "(", "child", ",", "ancestry", ")", "return", "(", ...
[ 134, 4 ]
[ 145, 25 ]
python
en
['en', 'error', 'th']
False
SchemaObject.get_child
(self, name)
Get (find) a I{non-attribute} child by name. @param name: A child name. @type name: str @return: A tuple: the requested (child, ancestry). @rtype: (L{SchemaObject}, [L{SchemaObject},..])
Get (find) a I{non-attribute} child by name.
def get_child(self, name): """ Get (find) a I{non-attribute} child by name. @param name: A child name. @type name: str @return: A tuple: the requested (child, ancestry). @rtype: (L{SchemaObject}, [L{SchemaObject},..]) """ for child, ancestry in self.childr...
[ "def", "get_child", "(", "self", ",", "name", ")", ":", "for", "child", ",", "ancestry", "in", "self", ".", "children", "(", ")", ":", "if", "child", ".", "any", "(", ")", "or", "child", ".", "name", "==", "name", ":", "return", "(", "child", ","...
[ 147, 4 ]
[ 158, 25 ]
python
en
['en', 'error', 'th']
False
SchemaObject.namespace
(self, prefix=None)
Get this properties namespace @param prefix: The default prefix. @type prefix: str @return: The schema's target namespace @rtype: (I{prefix},I{URI})
Get this properties namespace
def namespace(self, prefix=None): """ Get this properties namespace @param prefix: The default prefix. @type prefix: str @return: The schema's target namespace @rtype: (I{prefix},I{URI}) """ ns = self.schema.tns if ns[0] is None: ns = (...
[ "def", "namespace", "(", "self", ",", "prefix", "=", "None", ")", ":", "ns", "=", "self", ".", "schema", ".", "tns", "if", "ns", "[", "0", "]", "is", "None", ":", "ns", "=", "(", "prefix", ",", "ns", "[", "1", "]", ")", "return", "ns" ]
[ 160, 4 ]
[ 171, 17 ]
python
en
['en', 'error', 'th']
False
SchemaObject.unbounded
(self)
Get whether this node is unbounded I{(a collection)} @return: True if unbounded, else False. @rtype: boolean
Get whether this node is unbounded I{(a collection)}
def unbounded(self): """ Get whether this node is unbounded I{(a collection)} @return: True if unbounded, else False. @rtype: boolean """ max = self.max if max is None: max = '1' if max.isdigit(): return (int(max) > 1) else:...
[ "def", "unbounded", "(", "self", ")", ":", "max", "=", "self", ".", "max", "if", "max", "is", "None", ":", "max", "=", "'1'", "if", "max", ".", "isdigit", "(", ")", ":", "return", "(", "int", "(", "max", ")", ">", "1", ")", "else", ":", "retu...
[ 176, 4 ]
[ 188, 41 ]
python
en
['en', 'error', 'th']
False
SchemaObject.optional
(self)
Get whether this type is optional. @return: True if optional, else False @rtype: boolean
Get whether this type is optional.
def optional(self): """ Get whether this type is optional. @return: True if optional, else False @rtype: boolean """ min = self.min if min is None: min = '1' return ( min == '0' )
[ "def", "optional", "(", "self", ")", ":", "min", "=", "self", ".", "min", "if", "min", "is", "None", ":", "min", "=", "'1'", "return", "(", "min", "==", "'0'", ")" ]
[ 190, 4 ]
[ 199, 29 ]
python
en
['en', 'error', 'th']
False
SchemaObject.required
(self)
Get whether this type is required. @return: True if required, else False @rtype: boolean
Get whether this type is required.
def required(self): """ Get whether this type is required. @return: True if required, else False @rtype: boolean """ return ( not self.optional() )
[ "def", "required", "(", "self", ")", ":", "return", "(", "not", "self", ".", "optional", "(", ")", ")" ]
[ 201, 4 ]
[ 207, 38 ]
python
en
['en', 'error', 'th']
False
SchemaObject.resolve
(self, nobuiltin=False)
Resolve and return the nodes true self. @param nobuiltin: Flag indicates that resolution must not continue to include xsd builtins. @return: The resolved (true) type. @rtype: L{SchemaObject}
Resolve and return the nodes true self.
def resolve(self, nobuiltin=False): """ Resolve and return the nodes true self. @param nobuiltin: Flag indicates that resolution must not continue to include xsd builtins. @return: The resolved (true) type. @rtype: L{SchemaObject} """ return self.cache...
[ "def", "resolve", "(", "self", ",", "nobuiltin", "=", "False", ")", ":", "return", "self", ".", "cache", ".", "get", "(", "nobuiltin", ",", "self", ")" ]
[ 210, 4 ]
[ 218, 46 ]
python
en
['en', 'error', 'th']
False
SchemaObject.sequence
(self)
Get whether this is an <xs:sequence/> @return: True if <xs:sequence/>, else False @rtype: boolean
Get whether this is an <xs:sequence/>
def sequence(self): """ Get whether this is an <xs:sequence/> @return: True if <xs:sequence/>, else False @rtype: boolean """ return False
[ "def", "sequence", "(", "self", ")", ":", "return", "False" ]
[ 220, 4 ]
[ 226, 20 ]
python
en
['en', 'error', 'th']
False
SchemaObject.xslist
(self)
Get whether this is an <xs:list/> @return: True if any, else False @rtype: boolean
Get whether this is an <xs:list/>
def xslist(self): """ Get whether this is an <xs:list/> @return: True if any, else False @rtype: boolean """ return False
[ "def", "xslist", "(", "self", ")", ":", "return", "False" ]
[ 228, 4 ]
[ 234, 20 ]
python
en
['en', 'error', 'th']
False