repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
common-workflow-language/workflow-service
wes_service/cwl_runner.py
Workflow.run
def run(self, request, tempdir, opts): """ Constructs a command to run a cwl/json from requests and opts, runs it, and deposits the outputs in outdir. Runner: opts.getopt("runner", default="cwl-runner") CWL (url): request["workflow_url"] == a url to a cwl file ...
python
def run(self, request, tempdir, opts): """ Constructs a command to run a cwl/json from requests and opts, runs it, and deposits the outputs in outdir. Runner: opts.getopt("runner", default="cwl-runner") CWL (url): request["workflow_url"] == a url to a cwl file ...
[ "def", "run", "(", "self", ",", "request", ",", "tempdir", ",", "opts", ")", ":", "with", "open", "(", "os", ".", "path", ".", "join", "(", "self", ".", "workdir", ",", "\"request.json\"", ")", ",", "\"w\"", ")", "as", "f", ":", "json", ".", "dum...
Constructs a command to run a cwl/json from requests and opts, runs it, and deposits the outputs in outdir. Runner: opts.getopt("runner", default="cwl-runner") CWL (url): request["workflow_url"] == a url to a cwl file or request["workflow_attachment"] == input c...
[ "Constructs", "a", "command", "to", "run", "a", "cwl", "/", "json", "from", "requests", "and", "opts", "runs", "it", "and", "deposits", "the", "outputs", "in", "outdir", "." ]
train
https://github.com/common-workflow-language/workflow-service/blob/e879604b65c55546e4f87be1c9df9903a3e0b896/wes_service/cwl_runner.py#L19-L79
common-workflow-language/workflow-service
wes_service/cwl_runner.py
Workflow.getstate
def getstate(self): """ Returns RUNNING, -1 COMPLETE, 0 or EXECUTOR_ERROR, 255 """ state = "RUNNING" exit_code = -1 exitcode_file = os.path.join(self.workdir, "exit_code") pid_file = os.path.join(self.workdir, "pid"...
python
def getstate(self): """ Returns RUNNING, -1 COMPLETE, 0 or EXECUTOR_ERROR, 255 """ state = "RUNNING" exit_code = -1 exitcode_file = os.path.join(self.workdir, "exit_code") pid_file = os.path.join(self.workdir, "pid"...
[ "def", "getstate", "(", "self", ")", ":", "state", "=", "\"RUNNING\"", "exit_code", "=", "-", "1", "exitcode_file", "=", "os", ".", "path", ".", "join", "(", "self", ".", "workdir", ",", "\"exit_code\"", ")", "pid_file", "=", "os", ".", "path", ".", ...
Returns RUNNING, -1 COMPLETE, 0 or EXECUTOR_ERROR, 255
[ "Returns", "RUNNING", "-", "1", "COMPLETE", "0", "or", "EXECUTOR_ERROR", "255" ]
train
https://github.com/common-workflow-language/workflow-service/blob/e879604b65c55546e4f87be1c9df9903a3e0b896/wes_service/cwl_runner.py#L81-L116
common-workflow-language/workflow-service
wes_service/toil_wes.py
ToilWorkflow.write_workflow
def write_workflow(self, request, opts, cwd, wftype='cwl'): """Writes a cwl, wdl, or python file as appropriate from the request dictionary.""" workflow_url = request.get("workflow_url") # link the cwl and json into the cwd if workflow_url.startswith('file://'): os.link(wor...
python
def write_workflow(self, request, opts, cwd, wftype='cwl'): """Writes a cwl, wdl, or python file as appropriate from the request dictionary.""" workflow_url = request.get("workflow_url") # link the cwl and json into the cwd if workflow_url.startswith('file://'): os.link(wor...
[ "def", "write_workflow", "(", "self", ",", "request", ",", "opts", ",", "cwd", ",", "wftype", "=", "'cwl'", ")", ":", "workflow_url", "=", "request", ".", "get", "(", "\"workflow_url\"", ")", "# link the cwl and json into the cwd", "if", "workflow_url", ".", "...
Writes a cwl, wdl, or python file as appropriate from the request dictionary.
[ "Writes", "a", "cwl", "wdl", "or", "python", "file", "as", "appropriate", "from", "the", "request", "dictionary", "." ]
train
https://github.com/common-workflow-language/workflow-service/blob/e879604b65c55546e4f87be1c9df9903a3e0b896/wes_service/toil_wes.py#L68-L90
common-workflow-language/workflow-service
wes_service/toil_wes.py
ToilWorkflow.call_cmd
def call_cmd(self, cmd, cwd): """ Calls a command with Popen. Writes stdout, stderr, and the command to separate files. :param cmd: A string or array of strings. :param tempdir: :return: The pid of the command. """ with open(self.cmdfile, 'w') as f: ...
python
def call_cmd(self, cmd, cwd): """ Calls a command with Popen. Writes stdout, stderr, and the command to separate files. :param cmd: A string or array of strings. :param tempdir: :return: The pid of the command. """ with open(self.cmdfile, 'w') as f: ...
[ "def", "call_cmd", "(", "self", ",", "cmd", ",", "cwd", ")", ":", "with", "open", "(", "self", ".", "cmdfile", ",", "'w'", ")", "as", "f", ":", "f", ".", "write", "(", "str", "(", "cmd", ")", ")", "stdout", "=", "open", "(", "self", ".", "out...
Calls a command with Popen. Writes stdout, stderr, and the command to separate files. :param cmd: A string or array of strings. :param tempdir: :return: The pid of the command.
[ "Calls", "a", "command", "with", "Popen", ".", "Writes", "stdout", "stderr", "and", "the", "command", "to", "separate", "files", "." ]
train
https://github.com/common-workflow-language/workflow-service/blob/e879604b65c55546e4f87be1c9df9903a3e0b896/wes_service/toil_wes.py#L98-L120
common-workflow-language/workflow-service
wes_service/toil_wes.py
ToilWorkflow.run
def run(self, request, tempdir, opts): """ Constructs a command to run a cwl/json from requests and opts, runs it, and deposits the outputs in outdir. Runner: opts.getopt("runner", default="cwl-runner") CWL (url): request["workflow_url"] == a url to a cwl file ...
python
def run(self, request, tempdir, opts): """ Constructs a command to run a cwl/json from requests and opts, runs it, and deposits the outputs in outdir. Runner: opts.getopt("runner", default="cwl-runner") CWL (url): request["workflow_url"] == a url to a cwl file ...
[ "def", "run", "(", "self", ",", "request", ",", "tempdir", ",", "opts", ")", ":", "wftype", "=", "request", "[", "'workflow_type'", "]", ".", "lower", "(", ")", ".", "strip", "(", ")", "version", "=", "request", "[", "'workflow_type_version'", "]", "if...
Constructs a command to run a cwl/json from requests and opts, runs it, and deposits the outputs in outdir. Runner: opts.getopt("runner", default="cwl-runner") CWL (url): request["workflow_url"] == a url to a cwl file or request["workflow_attachment"] == input c...
[ "Constructs", "a", "command", "to", "run", "a", "cwl", "/", "json", "from", "requests", "and", "opts", "runs", "it", "and", "deposits", "the", "outputs", "in", "outdir", "." ]
train
https://github.com/common-workflow-language/workflow-service/blob/e879604b65c55546e4f87be1c9df9903a3e0b896/wes_service/toil_wes.py#L173-L222
common-workflow-language/workflow-service
wes_service/toil_wes.py
ToilWorkflow.getstate
def getstate(self): """ Returns QUEUED, -1 INITIALIZING, -1 RUNNING, -1 COMPLETE, 0 or EXECUTOR_ERROR, 255 """ # the jobstore never existed if not os.path.exists(self.jobst...
python
def getstate(self): """ Returns QUEUED, -1 INITIALIZING, -1 RUNNING, -1 COMPLETE, 0 or EXECUTOR_ERROR, 255 """ # the jobstore never existed if not os.path.exists(self.jobst...
[ "def", "getstate", "(", "self", ")", ":", "# the jobstore never existed", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "jobstorefile", ")", ":", "logging", ".", "info", "(", "'Workflow '", "+", "self", ".", "run_id", "+", "': QUEUED'", ...
Returns QUEUED, -1 INITIALIZING, -1 RUNNING, -1 COMPLETE, 0 or EXECUTOR_ERROR, 255
[ "Returns", "QUEUED", "-", "1", "INITIALIZING", "-", "1", "RUNNING", "-", "1", "COMPLETE", "0", "or", "EXECUTOR_ERROR", "255" ]
train
https://github.com/common-workflow-language/workflow-service/blob/e879604b65c55546e4f87be1c9df9903a3e0b896/wes_service/toil_wes.py#L224-L271
common-workflow-language/workflow-service
wes_service/util.py
visit
def visit(d, op): """Recursively call op(d) for all list subelements and dictionary 'values' that d may have.""" op(d) if isinstance(d, list): for i in d: visit(i, op) elif isinstance(d, dict): for i in itervalues(d): visit(i, op)
python
def visit(d, op): """Recursively call op(d) for all list subelements and dictionary 'values' that d may have.""" op(d) if isinstance(d, list): for i in d: visit(i, op) elif isinstance(d, dict): for i in itervalues(d): visit(i, op)
[ "def", "visit", "(", "d", ",", "op", ")", ":", "op", "(", "d", ")", "if", "isinstance", "(", "d", ",", "list", ")", ":", "for", "i", "in", "d", ":", "visit", "(", "i", ",", "op", ")", "elif", "isinstance", "(", "d", ",", "dict", ")", ":", ...
Recursively call op(d) for all list subelements and dictionary 'values' that d may have.
[ "Recursively", "call", "op", "(", "d", ")", "for", "all", "list", "subelements", "and", "dictionary", "values", "that", "d", "may", "have", "." ]
train
https://github.com/common-workflow-language/workflow-service/blob/e879604b65c55546e4f87be1c9df9903a3e0b896/wes_service/util.py#L11-L19
common-workflow-language/workflow-service
wes_service/util.py
WESBackend.getopt
def getopt(self, p, default=None): """Returns the first option value stored that matches p or default.""" for k, v in self.pairs: if k == p: return v return default
python
def getopt(self, p, default=None): """Returns the first option value stored that matches p or default.""" for k, v in self.pairs: if k == p: return v return default
[ "def", "getopt", "(", "self", ",", "p", ",", "default", "=", "None", ")", ":", "for", "k", ",", "v", "in", "self", ".", "pairs", ":", "if", "k", "==", "p", ":", "return", "v", "return", "default" ]
Returns the first option value stored that matches p or default.
[ "Returns", "the", "first", "option", "value", "stored", "that", "matches", "p", "or", "default", "." ]
train
https://github.com/common-workflow-language/workflow-service/blob/e879604b65c55546e4f87be1c9df9903a3e0b896/wes_service/util.py#L31-L36
common-workflow-language/workflow-service
wes_service/util.py
WESBackend.getoptlist
def getoptlist(self, p): """Returns all option values stored that match p as a list.""" optlist = [] for k, v in self.pairs: if k == p: optlist.append(v) return optlist
python
def getoptlist(self, p): """Returns all option values stored that match p as a list.""" optlist = [] for k, v in self.pairs: if k == p: optlist.append(v) return optlist
[ "def", "getoptlist", "(", "self", ",", "p", ")", ":", "optlist", "=", "[", "]", "for", "k", ",", "v", "in", "self", ".", "pairs", ":", "if", "k", "==", "p", ":", "optlist", ".", "append", "(", "v", ")", "return", "optlist" ]
Returns all option values stored that match p as a list.
[ "Returns", "all", "option", "values", "stored", "that", "match", "p", "as", "a", "list", "." ]
train
https://github.com/common-workflow-language/workflow-service/blob/e879604b65c55546e4f87be1c9df9903a3e0b896/wes_service/util.py#L38-L44
common-workflow-language/workflow-service
wes_service/arvados_wes.py
catch_exceptions
def catch_exceptions(orig_func): """Catch uncaught exceptions and turn them into http errors""" @functools.wraps(orig_func) def catch_exceptions_wrapper(self, *args, **kwargs): try: return orig_func(self, *args, **kwargs) except arvados.errors.ApiError as e: logging....
python
def catch_exceptions(orig_func): """Catch uncaught exceptions and turn them into http errors""" @functools.wraps(orig_func) def catch_exceptions_wrapper(self, *args, **kwargs): try: return orig_func(self, *args, **kwargs) except arvados.errors.ApiError as e: logging....
[ "def", "catch_exceptions", "(", "orig_func", ")", ":", "@", "functools", ".", "wraps", "(", "orig_func", ")", "def", "catch_exceptions_wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "orig_func", "(", "se...
Catch uncaught exceptions and turn them into http errors
[ "Catch", "uncaught", "exceptions", "and", "turn", "them", "into", "http", "errors" ]
train
https://github.com/common-workflow-language/workflow-service/blob/e879604b65c55546e4f87be1c9df9903a3e0b896/wes_service/arvados_wes.py#L46-L65
pudo/normality
normality/paths.py
_safe_name
def _safe_name(file_name, sep): """Convert the file name to ASCII and normalize the string.""" file_name = stringify(file_name) if file_name is None: return file_name = ascii_text(file_name) file_name = category_replace(file_name, UNICODE_CATEGORIES) file_name = collapse_spaces(file_name...
python
def _safe_name(file_name, sep): """Convert the file name to ASCII and normalize the string.""" file_name = stringify(file_name) if file_name is None: return file_name = ascii_text(file_name) file_name = category_replace(file_name, UNICODE_CATEGORIES) file_name = collapse_spaces(file_name...
[ "def", "_safe_name", "(", "file_name", ",", "sep", ")", ":", "file_name", "=", "stringify", "(", "file_name", ")", "if", "file_name", "is", "None", ":", "return", "file_name", "=", "ascii_text", "(", "file_name", ")", "file_name", "=", "category_replace", "(...
Convert the file name to ASCII and normalize the string.
[ "Convert", "the", "file", "name", "to", "ASCII", "and", "normalize", "the", "string", "." ]
train
https://github.com/pudo/normality/blob/b53cc2c6e5c6205573d2010f72d90808710a4b58/normality/paths.py#L11-L21
pudo/normality
normality/paths.py
safe_filename
def safe_filename(file_name, sep='_', default=None, extension=None): """Create a secure filename for plain file system storage.""" if file_name is None: return decode_path(default) file_name = decode_path(file_name) file_name = os.path.basename(file_name) file_name, _extension = os.path.spl...
python
def safe_filename(file_name, sep='_', default=None, extension=None): """Create a secure filename for plain file system storage.""" if file_name is None: return decode_path(default) file_name = decode_path(file_name) file_name = os.path.basename(file_name) file_name, _extension = os.path.spl...
[ "def", "safe_filename", "(", "file_name", ",", "sep", "=", "'_'", ",", "default", "=", "None", ",", "extension", "=", "None", ")", ":", "if", "file_name", "is", "None", ":", "return", "decode_path", "(", "default", ")", "file_name", "=", "decode_path", "...
Create a secure filename for plain file system storage.
[ "Create", "a", "secure", "filename", "for", "plain", "file", "system", "storage", "." ]
train
https://github.com/pudo/normality/blob/b53cc2c6e5c6205573d2010f72d90808710a4b58/normality/paths.py#L24-L40
pudo/normality
normality/stringify.py
stringify
def stringify(value, encoding_default='utf-8', encoding=None): """Brute-force convert a given object to a string. This will attempt an increasingly mean set of conversions to make a given object into a unicode string. It is guaranteed to either return unicode or None, if all conversions failed (or the ...
python
def stringify(value, encoding_default='utf-8', encoding=None): """Brute-force convert a given object to a string. This will attempt an increasingly mean set of conversions to make a given object into a unicode string. It is guaranteed to either return unicode or None, if all conversions failed (or the ...
[ "def", "stringify", "(", "value", ",", "encoding_default", "=", "'utf-8'", ",", "encoding", "=", "None", ")", ":", "if", "value", "is", "None", ":", "return", "None", "if", "not", "isinstance", "(", "value", ",", "six", ".", "text_type", ")", ":", "if"...
Brute-force convert a given object to a string. This will attempt an increasingly mean set of conversions to make a given object into a unicode string. It is guaranteed to either return unicode or None, if all conversions failed (or the value is indeed empty).
[ "Brute", "-", "force", "convert", "a", "given", "object", "to", "a", "string", "." ]
train
https://github.com/pudo/normality/blob/b53cc2c6e5c6205573d2010f72d90808710a4b58/normality/stringify.py#L10-L38
pudo/normality
normality/encoding.py
normalize_encoding
def normalize_encoding(encoding, default=DEFAULT_ENCODING): """Normalize the encoding name, replace ASCII w/ UTF-8.""" if encoding is None: return default encoding = encoding.lower().strip() if encoding in ['', 'ascii']: return default try: codecs.lookup(encoding) ret...
python
def normalize_encoding(encoding, default=DEFAULT_ENCODING): """Normalize the encoding name, replace ASCII w/ UTF-8.""" if encoding is None: return default encoding = encoding.lower().strip() if encoding in ['', 'ascii']: return default try: codecs.lookup(encoding) ret...
[ "def", "normalize_encoding", "(", "encoding", ",", "default", "=", "DEFAULT_ENCODING", ")", ":", "if", "encoding", "is", "None", ":", "return", "default", "encoding", "=", "encoding", ".", "lower", "(", ")", ".", "strip", "(", ")", "if", "encoding", "in", ...
Normalize the encoding name, replace ASCII w/ UTF-8.
[ "Normalize", "the", "encoding", "name", "replace", "ASCII", "w", "/", "UTF", "-", "8", "." ]
train
https://github.com/pudo/normality/blob/b53cc2c6e5c6205573d2010f72d90808710a4b58/normality/encoding.py#L8-L19
pudo/normality
normality/encoding.py
normalize_result
def normalize_result(result, default, threshold=0.2): """Interpret a chardet result.""" if result is None: return default if result.get('confidence') is None: return default if result.get('confidence') < threshold: return default return normalize_encoding(result.get('encoding...
python
def normalize_result(result, default, threshold=0.2): """Interpret a chardet result.""" if result is None: return default if result.get('confidence') is None: return default if result.get('confidence') < threshold: return default return normalize_encoding(result.get('encoding...
[ "def", "normalize_result", "(", "result", ",", "default", ",", "threshold", "=", "0.2", ")", ":", "if", "result", "is", "None", ":", "return", "default", "if", "result", ".", "get", "(", "'confidence'", ")", "is", "None", ":", "return", "default", "if", ...
Interpret a chardet result.
[ "Interpret", "a", "chardet", "result", "." ]
train
https://github.com/pudo/normality/blob/b53cc2c6e5c6205573d2010f72d90808710a4b58/normality/encoding.py#L22-L31
pudo/normality
normality/encoding.py
guess_encoding
def guess_encoding(text, default=DEFAULT_ENCODING): """Guess string encoding. Given a piece of text, apply character encoding detection to guess the appropriate encoding of the text. """ result = chardet.detect(text) return normalize_result(result, default=default)
python
def guess_encoding(text, default=DEFAULT_ENCODING): """Guess string encoding. Given a piece of text, apply character encoding detection to guess the appropriate encoding of the text. """ result = chardet.detect(text) return normalize_result(result, default=default)
[ "def", "guess_encoding", "(", "text", ",", "default", "=", "DEFAULT_ENCODING", ")", ":", "result", "=", "chardet", ".", "detect", "(", "text", ")", "return", "normalize_result", "(", "result", ",", "default", "=", "default", ")" ]
Guess string encoding. Given a piece of text, apply character encoding detection to guess the appropriate encoding of the text.
[ "Guess", "string", "encoding", "." ]
train
https://github.com/pudo/normality/blob/b53cc2c6e5c6205573d2010f72d90808710a4b58/normality/encoding.py#L34-L41
pudo/normality
normality/encoding.py
guess_file_encoding
def guess_file_encoding(fh, default=DEFAULT_ENCODING): """Guess encoding from a file handle.""" start = fh.tell() detector = chardet.UniversalDetector() while True: data = fh.read(1024 * 10) if not data: detector.close() break detector.feed(data) i...
python
def guess_file_encoding(fh, default=DEFAULT_ENCODING): """Guess encoding from a file handle.""" start = fh.tell() detector = chardet.UniversalDetector() while True: data = fh.read(1024 * 10) if not data: detector.close() break detector.feed(data) i...
[ "def", "guess_file_encoding", "(", "fh", ",", "default", "=", "DEFAULT_ENCODING", ")", ":", "start", "=", "fh", ".", "tell", "(", ")", "detector", "=", "chardet", ".", "UniversalDetector", "(", ")", "while", "True", ":", "data", "=", "fh", ".", "read", ...
Guess encoding from a file handle.
[ "Guess", "encoding", "from", "a", "file", "handle", "." ]
train
https://github.com/pudo/normality/blob/b53cc2c6e5c6205573d2010f72d90808710a4b58/normality/encoding.py#L44-L58
pudo/normality
normality/encoding.py
guess_path_encoding
def guess_path_encoding(file_path, default=DEFAULT_ENCODING): """Wrapper to open that damn file for you, lazy bastard.""" with io.open(file_path, 'rb') as fh: return guess_file_encoding(fh, default=default)
python
def guess_path_encoding(file_path, default=DEFAULT_ENCODING): """Wrapper to open that damn file for you, lazy bastard.""" with io.open(file_path, 'rb') as fh: return guess_file_encoding(fh, default=default)
[ "def", "guess_path_encoding", "(", "file_path", ",", "default", "=", "DEFAULT_ENCODING", ")", ":", "with", "io", ".", "open", "(", "file_path", ",", "'rb'", ")", "as", "fh", ":", "return", "guess_file_encoding", "(", "fh", ",", "default", "=", "default", "...
Wrapper to open that damn file for you, lazy bastard.
[ "Wrapper", "to", "open", "that", "damn", "file", "for", "you", "lazy", "bastard", "." ]
train
https://github.com/pudo/normality/blob/b53cc2c6e5c6205573d2010f72d90808710a4b58/normality/encoding.py#L61-L64
pudo/normality
normality/cleaning.py
decompose_nfkd
def decompose_nfkd(text): """Perform unicode compatibility decomposition. This will replace some non-standard value representations in unicode and normalise them, while also separating characters and their diacritics into two separate codepoints. """ if text is None: return None if ...
python
def decompose_nfkd(text): """Perform unicode compatibility decomposition. This will replace some non-standard value representations in unicode and normalise them, while also separating characters and their diacritics into two separate codepoints. """ if text is None: return None if ...
[ "def", "decompose_nfkd", "(", "text", ")", ":", "if", "text", "is", "None", ":", "return", "None", "if", "not", "hasattr", "(", "decompose_nfkd", ",", "'_tr'", ")", ":", "decompose_nfkd", ".", "_tr", "=", "Transliterator", ".", "createInstance", "(", "'Any...
Perform unicode compatibility decomposition. This will replace some non-standard value representations in unicode and normalise them, while also separating characters and their diacritics into two separate codepoints.
[ "Perform", "unicode", "compatibility", "decomposition", "." ]
train
https://github.com/pudo/normality/blob/b53cc2c6e5c6205573d2010f72d90808710a4b58/normality/cleaning.py#L17-L28
pudo/normality
normality/cleaning.py
compose_nfc
def compose_nfc(text): """Perform unicode composition.""" if text is None: return None if not hasattr(compose_nfc, '_tr'): compose_nfc._tr = Transliterator.createInstance('Any-NFC') return compose_nfc._tr.transliterate(text)
python
def compose_nfc(text): """Perform unicode composition.""" if text is None: return None if not hasattr(compose_nfc, '_tr'): compose_nfc._tr = Transliterator.createInstance('Any-NFC') return compose_nfc._tr.transliterate(text)
[ "def", "compose_nfc", "(", "text", ")", ":", "if", "text", "is", "None", ":", "return", "None", "if", "not", "hasattr", "(", "compose_nfc", ",", "'_tr'", ")", ":", "compose_nfc", ".", "_tr", "=", "Transliterator", ".", "createInstance", "(", "'Any-NFC'", ...
Perform unicode composition.
[ "Perform", "unicode", "composition", "." ]
train
https://github.com/pudo/normality/blob/b53cc2c6e5c6205573d2010f72d90808710a4b58/normality/cleaning.py#L31-L37
pudo/normality
normality/cleaning.py
category_replace
def category_replace(text, replacements=UNICODE_CATEGORIES): """Remove characters from a string based on unicode classes. This is a method for removing non-text characters (such as punctuation, whitespace, marks and diacritics) from a piece of text by class, rather than specifying them individually. ...
python
def category_replace(text, replacements=UNICODE_CATEGORIES): """Remove characters from a string based on unicode classes. This is a method for removing non-text characters (such as punctuation, whitespace, marks and diacritics) from a piece of text by class, rather than specifying them individually. ...
[ "def", "category_replace", "(", "text", ",", "replacements", "=", "UNICODE_CATEGORIES", ")", ":", "if", "text", "is", "None", ":", "return", "None", "characters", "=", "[", "]", "for", "character", "in", "decompose_nfkd", "(", "text", ")", ":", "cat", "=",...
Remove characters from a string based on unicode classes. This is a method for removing non-text characters (such as punctuation, whitespace, marks and diacritics) from a piece of text by class, rather than specifying them individually.
[ "Remove", "characters", "from", "a", "string", "based", "on", "unicode", "classes", "." ]
train
https://github.com/pudo/normality/blob/b53cc2c6e5c6205573d2010f72d90808710a4b58/normality/cleaning.py#L47-L62
pudo/normality
normality/cleaning.py
remove_unsafe_chars
def remove_unsafe_chars(text): """Remove unsafe unicode characters from a piece of text.""" if isinstance(text, six.string_types): text = UNSAFE_RE.sub('', text) return text
python
def remove_unsafe_chars(text): """Remove unsafe unicode characters from a piece of text.""" if isinstance(text, six.string_types): text = UNSAFE_RE.sub('', text) return text
[ "def", "remove_unsafe_chars", "(", "text", ")", ":", "if", "isinstance", "(", "text", ",", "six", ".", "string_types", ")", ":", "text", "=", "UNSAFE_RE", ".", "sub", "(", "''", ",", "text", ")", "return", "text" ]
Remove unsafe unicode characters from a piece of text.
[ "Remove", "unsafe", "unicode", "characters", "from", "a", "piece", "of", "text", "." ]
train
https://github.com/pudo/normality/blob/b53cc2c6e5c6205573d2010f72d90808710a4b58/normality/cleaning.py#L70-L74
pudo/normality
normality/cleaning.py
collapse_spaces
def collapse_spaces(text): """Remove newlines, tabs and multiple spaces with single spaces.""" if not isinstance(text, six.string_types): return text return COLLAPSE_RE.sub(WS, text).strip(WS)
python
def collapse_spaces(text): """Remove newlines, tabs and multiple spaces with single spaces.""" if not isinstance(text, six.string_types): return text return COLLAPSE_RE.sub(WS, text).strip(WS)
[ "def", "collapse_spaces", "(", "text", ")", ":", "if", "not", "isinstance", "(", "text", ",", "six", ".", "string_types", ")", ":", "return", "text", "return", "COLLAPSE_RE", ".", "sub", "(", "WS", ",", "text", ")", ".", "strip", "(", "WS", ")" ]
Remove newlines, tabs and multiple spaces with single spaces.
[ "Remove", "newlines", "tabs", "and", "multiple", "spaces", "with", "single", "spaces", "." ]
train
https://github.com/pudo/normality/blob/b53cc2c6e5c6205573d2010f72d90808710a4b58/normality/cleaning.py#L82-L86
pudo/normality
normality/__init__.py
normalize
def normalize(text, lowercase=True, collapse=True, latinize=False, ascii=False, encoding_default='utf-8', encoding=None, replace_categories=UNICODE_CATEGORIES): """The main normalization function for text. This will take a string and apply a set of transformations to it so that ...
python
def normalize(text, lowercase=True, collapse=True, latinize=False, ascii=False, encoding_default='utf-8', encoding=None, replace_categories=UNICODE_CATEGORIES): """The main normalization function for text. This will take a string and apply a set of transformations to it so that ...
[ "def", "normalize", "(", "text", ",", "lowercase", "=", "True", ",", "collapse", "=", "True", ",", "latinize", "=", "False", ",", "ascii", "=", "False", ",", "encoding_default", "=", "'utf-8'", ",", "encoding", "=", "None", ",", "replace_categories", "=", ...
The main normalization function for text. This will take a string and apply a set of transformations to it so that it can be processed more easily afterwards. Arguments: * ``lowercase``: not very mysterious. * ``collapse``: replace multiple whitespace-like characters with a single whitespace. Th...
[ "The", "main", "normalization", "function", "for", "text", "." ]
train
https://github.com/pudo/normality/blob/b53cc2c6e5c6205573d2010f72d90808710a4b58/normality/__init__.py#L9-L57
pudo/normality
normality/__init__.py
slugify
def slugify(text, sep='-'): """A simple slug generator.""" text = stringify(text) if text is None: return None text = text.replace(sep, WS) text = normalize(text, ascii=True) if text is None: return None return text.replace(WS, sep)
python
def slugify(text, sep='-'): """A simple slug generator.""" text = stringify(text) if text is None: return None text = text.replace(sep, WS) text = normalize(text, ascii=True) if text is None: return None return text.replace(WS, sep)
[ "def", "slugify", "(", "text", ",", "sep", "=", "'-'", ")", ":", "text", "=", "stringify", "(", "text", ")", "if", "text", "is", "None", ":", "return", "None", "text", "=", "text", ".", "replace", "(", "sep", ",", "WS", ")", "text", "=", "normali...
A simple slug generator.
[ "A", "simple", "slug", "generator", "." ]
train
https://github.com/pudo/normality/blob/b53cc2c6e5c6205573d2010f72d90808710a4b58/normality/__init__.py#L60-L69
pudo/normality
normality/transliteration.py
latinize_text
def latinize_text(text, ascii=False): """Transliterate the given text to the latin script. This attempts to convert a given text to latin script using the closest match of characters vis a vis the original script. """ if text is None or not isinstance(text, six.string_types) or not len(text): ...
python
def latinize_text(text, ascii=False): """Transliterate the given text to the latin script. This attempts to convert a given text to latin script using the closest match of characters vis a vis the original script. """ if text is None or not isinstance(text, six.string_types) or not len(text): ...
[ "def", "latinize_text", "(", "text", ",", "ascii", "=", "False", ")", ":", "if", "text", "is", "None", "or", "not", "isinstance", "(", "text", ",", "six", ".", "string_types", ")", "or", "not", "len", "(", "text", ")", ":", "return", "text", "if", ...
Transliterate the given text to the latin script. This attempts to convert a given text to latin script using the closest match of characters vis a vis the original script.
[ "Transliterate", "the", "given", "text", "to", "the", "latin", "script", "." ]
train
https://github.com/pudo/normality/blob/b53cc2c6e5c6205573d2010f72d90808710a4b58/normality/transliteration.py#L18-L36
pudo/normality
normality/transliteration.py
ascii_text
def ascii_text(text): """Transliterate the given text and make sure it ends up as ASCII.""" text = latinize_text(text, ascii=True) if isinstance(text, six.text_type): text = text.encode('ascii', 'ignore').decode('ascii') return text
python
def ascii_text(text): """Transliterate the given text and make sure it ends up as ASCII.""" text = latinize_text(text, ascii=True) if isinstance(text, six.text_type): text = text.encode('ascii', 'ignore').decode('ascii') return text
[ "def", "ascii_text", "(", "text", ")", ":", "text", "=", "latinize_text", "(", "text", ",", "ascii", "=", "True", ")", "if", "isinstance", "(", "text", ",", "six", ".", "text_type", ")", ":", "text", "=", "text", ".", "encode", "(", "'ascii'", ",", ...
Transliterate the given text and make sure it ends up as ASCII.
[ "Transliterate", "the", "given", "text", "and", "make", "sure", "it", "ends", "up", "as", "ASCII", "." ]
train
https://github.com/pudo/normality/blob/b53cc2c6e5c6205573d2010f72d90808710a4b58/normality/transliteration.py#L39-L44
SolutionsCloud/apidoc
apidoc/object/source_raw.py
Method.message
def message(self): """Return default message for this element """ if self.code != 200: for code in self.response_codes: if code.code == self.code: return code.message raise ValueError("Unknown response code \"%s\" in \"%s\"." % (self.c...
python
def message(self): """Return default message for this element """ if self.code != 200: for code in self.response_codes: if code.code == self.code: return code.message raise ValueError("Unknown response code \"%s\" in \"%s\"." % (self.c...
[ "def", "message", "(", "self", ")", ":", "if", "self", ".", "code", "!=", "200", ":", "for", "code", "in", "self", ".", "response_codes", ":", "if", "code", ".", "code", "==", "self", ".", "code", ":", "return", "code", ".", "message", "raise", "Va...
Return default message for this element
[ "Return", "default", "message", "for", "this", "element" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/object/source_raw.py#L162-L172
SolutionsCloud/apidoc
apidoc/object/source_raw.py
Parameter.get_default_sample
def get_default_sample(self): """Return default value for the element """ if self.type not in Object.Types or self.type is Object.Types.type: return self.type_object.get_sample() else: return self.get_object().get_sample()
python
def get_default_sample(self): """Return default value for the element """ if self.type not in Object.Types or self.type is Object.Types.type: return self.type_object.get_sample() else: return self.get_object().get_sample()
[ "def", "get_default_sample", "(", "self", ")", ":", "if", "self", ".", "type", "not", "in", "Object", ".", "Types", "or", "self", ".", "type", "is", "Object", ".", "Types", ".", "type", ":", "return", "self", ".", "type_object", ".", "get_sample", "(",...
Return default value for the element
[ "Return", "default", "value", "for", "the", "element" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/object/source_raw.py#L216-L222
SolutionsCloud/apidoc
apidoc/object/source_raw.py
Object.factory
def factory(cls, str_type, version): """Return a proper object """ type = Object.Types(str_type) if type is Object.Types.object: object = ObjectObject() elif type is Object.Types.array: object = ObjectArray() elif type is Object.Types.number: ...
python
def factory(cls, str_type, version): """Return a proper object """ type = Object.Types(str_type) if type is Object.Types.object: object = ObjectObject() elif type is Object.Types.array: object = ObjectArray() elif type is Object.Types.number: ...
[ "def", "factory", "(", "cls", ",", "str_type", ",", "version", ")", ":", "type", "=", "Object", ".", "Types", "(", "str_type", ")", "if", "type", "is", "Object", ".", "Types", ".", "object", ":", "object", "=", "ObjectObject", "(", ")", "elif", "type...
Return a proper object
[ "Return", "a", "proper", "object" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/object/source_raw.py#L327-L360
SolutionsCloud/apidoc
apidoc/command/run.py
main
def main(): """Main function to run command """ configParser = FileParser() logging.config.dictConfig( configParser.load_from_file(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'settings', 'logging.yml')) ) ApiDoc().main()
python
def main(): """Main function to run command """ configParser = FileParser() logging.config.dictConfig( configParser.load_from_file(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'settings', 'logging.yml')) ) ApiDoc().main()
[ "def", "main", "(", ")", ":", "configParser", "=", "FileParser", "(", ")", "logging", ".", "config", ".", "dictConfig", "(", "configParser", ".", "load_from_file", "(", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "os", ...
Main function to run command
[ "Main", "function", "to", "run", "command" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/command/run.py#L247-L254
SolutionsCloud/apidoc
apidoc/command/run.py
ApiDoc._init_config
def _init_config(self): """return command's configuration from call's arguments """ options = self.parser.parse_args() if options.config is None and options.input is None: self.parser.print_help() sys.exit(2) if options.config is not None: con...
python
def _init_config(self): """return command's configuration from call's arguments """ options = self.parser.parse_args() if options.config is None and options.input is None: self.parser.print_help() sys.exit(2) if options.config is not None: con...
[ "def", "_init_config", "(", "self", ")", ":", "options", "=", "self", ".", "parser", ".", "parse_args", "(", ")", "if", "options", ".", "config", "is", "None", "and", "options", ".", "input", "is", "None", ":", "self", ".", "parser", ".", "print_help",...
return command's configuration from call's arguments
[ "return", "command", "s", "configuration", "from", "call", "s", "arguments" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/command/run.py#L91-L130
SolutionsCloud/apidoc
apidoc/command/run.py
ApiDoc.main
def main(self): """Run the command """ self._init_config() if self.dry_run: return self.run_dry_run() elif self.watch: return self.run_watch() else: return self.run_render()
python
def main(self): """Run the command """ self._init_config() if self.dry_run: return self.run_dry_run() elif self.watch: return self.run_watch() else: return self.run_render()
[ "def", "main", "(", "self", ")", ":", "self", ".", "_init_config", "(", ")", "if", "self", ".", "dry_run", ":", "return", "self", ".", "run_dry_run", "(", ")", "elif", "self", ".", "watch", ":", "return", "self", ".", "run_watch", "(", ")", "else", ...
Run the command
[ "Run", "the", "command" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/command/run.py#L135-L145
SolutionsCloud/apidoc
apidoc/command/run.py
ApiDoc._watch_refresh_source
def _watch_refresh_source(self, event): """Refresh sources then templates """ self.logger.info("Sources changed...") try: self.sources = self._get_sources() self._render_template(self.sources) except: pass
python
def _watch_refresh_source(self, event): """Refresh sources then templates """ self.logger.info("Sources changed...") try: self.sources = self._get_sources() self._render_template(self.sources) except: pass
[ "def", "_watch_refresh_source", "(", "self", ",", "event", ")", ":", "self", ".", "logger", ".", "info", "(", "\"Sources changed...\"", ")", "try", ":", "self", ".", "sources", "=", "self", ".", "_get_sources", "(", ")", "self", ".", "_render_template", "(...
Refresh sources then templates
[ "Refresh", "sources", "then", "templates" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/command/run.py#L225-L234
SolutionsCloud/apidoc
apidoc/command/run.py
ApiDoc._watch_refresh_template
def _watch_refresh_template(self, event): """Refresh template's contents """ self.logger.info("Template changed...") try: self._render_template(self.sources) except: pass
python
def _watch_refresh_template(self, event): """Refresh template's contents """ self.logger.info("Template changed...") try: self._render_template(self.sources) except: pass
[ "def", "_watch_refresh_template", "(", "self", ",", "event", ")", ":", "self", ".", "logger", ".", "info", "(", "\"Template changed...\"", ")", "try", ":", "self", ".", "_render_template", "(", "self", ".", "sources", ")", "except", ":", "pass" ]
Refresh template's contents
[ "Refresh", "template", "s", "contents" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/command/run.py#L236-L244
SolutionsCloud/apidoc
apidoc/lib/util/decorator.py
add_property
def add_property(attribute, type): """Add a property to a class """ def decorator(cls): """Decorator """ private = "_" + attribute def getAttr(self): """Property getter """ if getattr(self, private) is None: setattr(self, p...
python
def add_property(attribute, type): """Add a property to a class """ def decorator(cls): """Decorator """ private = "_" + attribute def getAttr(self): """Property getter """ if getattr(self, private) is None: setattr(self, p...
[ "def", "add_property", "(", "attribute", ",", "type", ")", ":", "def", "decorator", "(", "cls", ")", ":", "\"\"\"Decorator\n \"\"\"", "private", "=", "\"_\"", "+", "attribute", "def", "getAttr", "(", "self", ")", ":", "\"\"\"Property getter\n \"\...
Add a property to a class
[ "Add", "a", "property", "to", "a", "class" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/lib/util/decorator.py#L3-L27
SolutionsCloud/apidoc
setup_cmd/__init__.py
Resource._merge_files
def _merge_files(self, input_files, output_file): """Combine the input files to a big output file""" # we assume that all the input files have the same charset with open(output_file, mode='wb') as out: for input_file in input_files: out.write(open(input_file, mode='rb...
python
def _merge_files(self, input_files, output_file): """Combine the input files to a big output file""" # we assume that all the input files have the same charset with open(output_file, mode='wb') as out: for input_file in input_files: out.write(open(input_file, mode='rb...
[ "def", "_merge_files", "(", "self", ",", "input_files", ",", "output_file", ")", ":", "# we assume that all the input files have the same charset", "with", "open", "(", "output_file", ",", "mode", "=", "'wb'", ")", "as", "out", ":", "for", "input_file", "in", "inp...
Combine the input files to a big output file
[ "Combine", "the", "input", "files", "to", "a", "big", "output", "file" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/setup_cmd/__init__.py#L118-L123
SolutionsCloud/apidoc
apidoc/factory/source/object.py
Object.create_from_name_and_dictionary
def create_from_name_and_dictionary(self, name, datas): """Return a populated object Object from dictionary datas """ if "type" not in datas: str_type = "any" else: str_type = str(datas["type"]).lower() if str_type not in ObjectRaw.Types: type...
python
def create_from_name_and_dictionary(self, name, datas): """Return a populated object Object from dictionary datas """ if "type" not in datas: str_type = "any" else: str_type = str(datas["type"]).lower() if str_type not in ObjectRaw.Types: type...
[ "def", "create_from_name_and_dictionary", "(", "self", ",", "name", ",", "datas", ")", ":", "if", "\"type\"", "not", "in", "datas", ":", "str_type", "=", "\"any\"", "else", ":", "str_type", "=", "str", "(", "datas", "[", "\"type\"", "]", ")", ".", "lower...
Return a populated object Object from dictionary datas
[ "Return", "a", "populated", "object", "Object", "from", "dictionary", "datas" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/factory/source/object.py#L13-L117
SolutionsCloud/apidoc
apidoc/service/merger.py
Merger.merge_extends
def merge_extends(self, target, extends, inherit_key="inherit", inherit=False): """Merge extended dicts """ if isinstance(target, dict): if inherit and inherit_key in target and not to_boolean(target[inherit_key]): return if not isinstance(extends, dict): ...
python
def merge_extends(self, target, extends, inherit_key="inherit", inherit=False): """Merge extended dicts """ if isinstance(target, dict): if inherit and inherit_key in target and not to_boolean(target[inherit_key]): return if not isinstance(extends, dict): ...
[ "def", "merge_extends", "(", "self", ",", "target", ",", "extends", ",", "inherit_key", "=", "\"inherit\"", ",", "inherit", "=", "False", ")", ":", "if", "isinstance", "(", "target", ",", "dict", ")", ":", "if", "inherit", "and", "inherit_key", "in", "ta...
Merge extended dicts
[ "Merge", "extended", "dicts" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/service/merger.py#L9-L25
SolutionsCloud/apidoc
apidoc/service/merger.py
Merger.merge_sources
def merge_sources(self, datas): """Merge sources files """ datas = [data for data in datas if data is not None] if len(datas) == 0: raise ValueError("Data missing") if len(datas) == 1: return datas[0] if isinstance(datas[0], list): i...
python
def merge_sources(self, datas): """Merge sources files """ datas = [data for data in datas if data is not None] if len(datas) == 0: raise ValueError("Data missing") if len(datas) == 1: return datas[0] if isinstance(datas[0], list): i...
[ "def", "merge_sources", "(", "self", ",", "datas", ")", ":", "datas", "=", "[", "data", "for", "data", "in", "datas", "if", "data", "is", "not", "None", "]", "if", "len", "(", "datas", ")", "==", "0", ":", "raise", "ValueError", "(", "\"Data missing\...
Merge sources files
[ "Merge", "sources", "files" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/service/merger.py#L27-L61
SolutionsCloud/apidoc
apidoc/service/merger.py
Merger.merge_configs
def merge_configs(self, config, datas): """Merge configs files """ if not isinstance(config, dict) or len([x for x in datas if not isinstance(x, dict)]) > 0: raise TypeError("Unable to merge: Dictionnary expected") for key, value in config.items(): others = [x[ke...
python
def merge_configs(self, config, datas): """Merge configs files """ if not isinstance(config, dict) or len([x for x in datas if not isinstance(x, dict)]) > 0: raise TypeError("Unable to merge: Dictionnary expected") for key, value in config.items(): others = [x[ke...
[ "def", "merge_configs", "(", "self", ",", "config", ",", "datas", ")", ":", "if", "not", "isinstance", "(", "config", ",", "dict", ")", "or", "len", "(", "[", "x", "for", "x", "in", "datas", "if", "not", "isinstance", "(", "x", ",", "dict", ")", ...
Merge configs files
[ "Merge", "configs", "files" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/service/merger.py#L63-L76
SolutionsCloud/apidoc
apidoc/object/source_sample.py
Object.factory
def factory(cls, object_raw): """Return a proper object """ if object_raw is None: return None if object_raw.type is ObjectRaw.Types.object: return ObjectObject(object_raw) elif object_raw.type is ObjectRaw.Types.type: return ObjectType(object_...
python
def factory(cls, object_raw): """Return a proper object """ if object_raw is None: return None if object_raw.type is ObjectRaw.Types.object: return ObjectObject(object_raw) elif object_raw.type is ObjectRaw.Types.type: return ObjectType(object_...
[ "def", "factory", "(", "cls", ",", "object_raw", ")", ":", "if", "object_raw", "is", "None", ":", "return", "None", "if", "object_raw", ".", "type", "is", "ObjectRaw", ".", "Types", ".", "object", ":", "return", "ObjectObject", "(", "object_raw", ")", "e...
Return a proper object
[ "Return", "a", "proper", "object" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/object/source_sample.py#L59-L77
SolutionsCloud/apidoc
apidoc/service/template.py
Template.render
def render(self, sources, config, out=sys.stdout): """Render the documentation as defined in config Object """ logger = logging.getLogger() template = self.env.get_template(self.input) output = template.render(sources=sources, layout=config["output"]["layout"], config=config["out...
python
def render(self, sources, config, out=sys.stdout): """Render the documentation as defined in config Object """ logger = logging.getLogger() template = self.env.get_template(self.input) output = template.render(sources=sources, layout=config["output"]["layout"], config=config["out...
[ "def", "render", "(", "self", ",", "sources", ",", "config", ",", "out", "=", "sys", ".", "stdout", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", ")", "template", "=", "self", ".", "env", ".", "get_template", "(", "self", ".", "input", ...
Render the documentation as defined in config Object
[ "Render", "the", "documentation", "as", "defined", "in", "config", "Object" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/service/template.py#L19-L84
SolutionsCloud/apidoc
apidoc/factory/source/configuration.py
Configuration.create_from_dictionary
def create_from_dictionary(self, datas): """Return a populated object Configuration from dictionnary datas """ configuration = ObjectConfiguration() if "uri" in datas: configuration.uri = str(datas["uri"]) if "title" in datas: configuration.title = str(da...
python
def create_from_dictionary(self, datas): """Return a populated object Configuration from dictionnary datas """ configuration = ObjectConfiguration() if "uri" in datas: configuration.uri = str(datas["uri"]) if "title" in datas: configuration.title = str(da...
[ "def", "create_from_dictionary", "(", "self", ",", "datas", ")", ":", "configuration", "=", "ObjectConfiguration", "(", ")", "if", "\"uri\"", "in", "datas", ":", "configuration", ".", "uri", "=", "str", "(", "datas", "[", "\"uri\"", "]", ")", "if", "\"titl...
Return a populated object Configuration from dictionnary datas
[ "Return", "a", "populated", "object", "Configuration", "from", "dictionnary", "datas" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/factory/source/configuration.py#L10-L22
SolutionsCloud/apidoc
apidoc/factory/source/parameter.py
Parameter.create_from_name_and_dictionary
def create_from_name_and_dictionary(self, name, datas): """Return a populated object Parameter from dictionary datas """ parameter = ObjectParameter() self.set_common_datas(parameter, name, datas) if "optional" in datas: parameter.optional = to_boolean(datas["optiona...
python
def create_from_name_and_dictionary(self, name, datas): """Return a populated object Parameter from dictionary datas """ parameter = ObjectParameter() self.set_common_datas(parameter, name, datas) if "optional" in datas: parameter.optional = to_boolean(datas["optiona...
[ "def", "create_from_name_and_dictionary", "(", "self", ",", "name", ",", "datas", ")", ":", "parameter", "=", "ObjectParameter", "(", ")", "self", ".", "set_common_datas", "(", "parameter", ",", "name", ",", "datas", ")", "if", "\"optional\"", "in", "datas", ...
Return a populated object Parameter from dictionary datas
[ "Return", "a", "populated", "object", "Parameter", "from", "dictionary", "datas" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/factory/source/parameter.py#L12-L25
SolutionsCloud/apidoc
apidoc/service/source.py
Source.validate
def validate(self, sources): """Validate the format of sources """ if not isinstance(sources, Root): raise Exception("Source object expected") parameters = self.get_uri_with_missing_parameters(sources) for parameter in parameters: logging.getLogger().warn...
python
def validate(self, sources): """Validate the format of sources """ if not isinstance(sources, Root): raise Exception("Source object expected") parameters = self.get_uri_with_missing_parameters(sources) for parameter in parameters: logging.getLogger().warn...
[ "def", "validate", "(", "self", ",", "sources", ")", ":", "if", "not", "isinstance", "(", "sources", ",", "Root", ")", ":", "raise", "Exception", "(", "\"Source object expected\"", ")", "parameters", "=", "self", ".", "get_uri_with_missing_parameters", "(", "s...
Validate the format of sources
[ "Validate", "the", "format", "of", "sources" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/service/source.py#L12-L20
SolutionsCloud/apidoc
apidoc/service/config.py
Config.validate
def validate(self, config): """Validate that the source file is ok """ if not isinstance(config, ConfigObject): raise Exception("Config object expected") if config["output"]["componants"] not in ("local", "remote", "embedded", "without"): raise ValueError("Unknow...
python
def validate(self, config): """Validate that the source file is ok """ if not isinstance(config, ConfigObject): raise Exception("Config object expected") if config["output"]["componants"] not in ("local", "remote", "embedded", "without"): raise ValueError("Unknow...
[ "def", "validate", "(", "self", ",", "config", ")", ":", "if", "not", "isinstance", "(", "config", ",", "ConfigObject", ")", ":", "raise", "Exception", "(", "\"Config object expected\"", ")", "if", "config", "[", "\"output\"", "]", "[", "\"componants\"", "]"...
Validate that the source file is ok
[ "Validate", "that", "the", "source", "file", "is", "ok" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/service/config.py#L10-L36
SolutionsCloud/apidoc
apidoc/service/config.py
Config.get_template_from_config
def get_template_from_config(self, config): """Retrieve a template path from the config object """ if config["output"]["template"] == "default": return os.path.join( os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'template', ...
python
def get_template_from_config(self, config): """Retrieve a template path from the config object """ if config["output"]["template"] == "default": return os.path.join( os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'template', ...
[ "def", "get_template_from_config", "(", "self", ",", "config", ")", ":", "if", "config", "[", "\"output\"", "]", "[", "\"template\"", "]", "==", "\"default\"", ":", "return", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", ...
Retrieve a template path from the config object
[ "Retrieve", "a", "template", "path", "from", "the", "config", "object" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/service/config.py#L38-L48
SolutionsCloud/apidoc
apidoc/factory/source/responseCode.py
ResponseCode.create_from_dictionary
def create_from_dictionary(self, datas): """Return a populated object ResponseCode from dictionary datas """ if "code" not in datas: raise ValueError("A response code must contain a code in \"%s\"." % repr(datas)) code = ObjectResponseCode() self.set_common_datas(cod...
python
def create_from_dictionary(self, datas): """Return a populated object ResponseCode from dictionary datas """ if "code" not in datas: raise ValueError("A response code must contain a code in \"%s\"." % repr(datas)) code = ObjectResponseCode() self.set_common_datas(cod...
[ "def", "create_from_dictionary", "(", "self", ",", "datas", ")", ":", "if", "\"code\"", "not", "in", "datas", ":", "raise", "ValueError", "(", "\"A response code must contain a code in \\\"%s\\\".\"", "%", "repr", "(", "datas", ")", ")", "code", "=", "ObjectRespon...
Return a populated object ResponseCode from dictionary datas
[ "Return", "a", "populated", "object", "ResponseCode", "from", "dictionary", "datas" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/factory/source/responseCode.py#L54-L71
SolutionsCloud/apidoc
apidoc/lib/fswatcher/observer.py
Observer.add_handler
def add_handler(self, path, handler): """Add a path in watch queue """ self.signatures[path] = self.get_path_signature(path) self.handlers[path] = handler
python
def add_handler(self, path, handler): """Add a path in watch queue """ self.signatures[path] = self.get_path_signature(path) self.handlers[path] = handler
[ "def", "add_handler", "(", "self", ",", "path", ",", "handler", ")", ":", "self", ".", "signatures", "[", "path", "]", "=", "self", ".", "get_path_signature", "(", "path", ")", "self", ".", "handlers", "[", "path", "]", "=", "handler" ]
Add a path in watch queue
[ "Add", "a", "path", "in", "watch", "queue" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/lib/fswatcher/observer.py#L19-L23
SolutionsCloud/apidoc
apidoc/lib/fswatcher/observer.py
Observer.get_path_signature
def get_path_signature(self, path): """generate a unique signature for file contained in path """ if not os.path.exists(path): return None if os.path.isdir(path): merge = {} for root, dirs, files in os.walk(path): for name in files: ...
python
def get_path_signature(self, path): """generate a unique signature for file contained in path """ if not os.path.exists(path): return None if os.path.isdir(path): merge = {} for root, dirs, files in os.walk(path): for name in files: ...
[ "def", "get_path_signature", "(", "self", ",", "path", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "return", "None", "if", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "merge", "=", "{", "}", "for", ...
generate a unique signature for file contained in path
[ "generate", "a", "unique", "signature", "for", "file", "contained", "in", "path" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/lib/fswatcher/observer.py#L25-L38
SolutionsCloud/apidoc
apidoc/lib/fswatcher/observer.py
Observer.check
def check(self): """Check if a file is changed """ for (path, handler) in self.handlers.items(): current_signature = self.signatures[path] new_signature = self.get_path_signature(path) if new_signature != current_signature: self.signatures[path...
python
def check(self): """Check if a file is changed """ for (path, handler) in self.handlers.items(): current_signature = self.signatures[path] new_signature = self.get_path_signature(path) if new_signature != current_signature: self.signatures[path...
[ "def", "check", "(", "self", ")", ":", "for", "(", "path", ",", "handler", ")", "in", "self", ".", "handlers", ".", "items", "(", ")", ":", "current_signature", "=", "self", ".", "signatures", "[", "path", "]", "new_signature", "=", "self", ".", "get...
Check if a file is changed
[ "Check", "if", "a", "file", "is", "changed" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/lib/fswatcher/observer.py#L40-L48
SolutionsCloud/apidoc
apidoc/object/source_dto.py
Version.get_comparable_values
def get_comparable_values(self): """Return a tupple of values representing the unicity of the object """ return (int(self.major), int(self.minor), str(self.label), str(self.name))
python
def get_comparable_values(self): """Return a tupple of values representing the unicity of the object """ return (int(self.major), int(self.minor), str(self.label), str(self.name))
[ "def", "get_comparable_values", "(", "self", ")", ":", "return", "(", "int", "(", "self", ".", "major", ")", ",", "int", "(", "self", ".", "minor", ")", ",", "str", "(", "self", ".", "label", ")", ",", "str", "(", "self", ".", "name", ")", ")" ]
Return a tupple of values representing the unicity of the object
[ "Return", "a", "tupple", "of", "values", "representing", "the", "unicity", "of", "the", "object" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/object/source_dto.py#L61-L64
SolutionsCloud/apidoc
apidoc/object/source_dto.py
Category.get_comparable_values
def get_comparable_values(self): """Return a tupple of values representing the unicity of the object """ return (int(self.order), str(self.label), str(self.name))
python
def get_comparable_values(self): """Return a tupple of values representing the unicity of the object """ return (int(self.order), str(self.label), str(self.name))
[ "def", "get_comparable_values", "(", "self", ")", ":", "return", "(", "int", "(", "self", ".", "order", ")", ",", "str", "(", "self", ".", "label", ")", ",", "str", "(", "self", ".", "name", ")", ")" ]
Return a tupple of values representing the unicity of the object
[ "Return", "a", "tupple", "of", "values", "representing", "the", "unicity", "of", "the", "object" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/object/source_dto.py#L80-L83
SolutionsCloud/apidoc
apidoc/object/source_dto.py
Parameter.get_comparable_values
def get_comparable_values(self): """Return a tupple of values representing the unicity of the object """ return (not self.generic, str(self.name), str(self.description))
python
def get_comparable_values(self): """Return a tupple of values representing the unicity of the object """ return (not self.generic, str(self.name), str(self.description))
[ "def", "get_comparable_values", "(", "self", ")", ":", "return", "(", "not", "self", ".", "generic", ",", "str", "(", "self", ".", "name", ")", ",", "str", "(", "self", ".", "description", ")", ")" ]
Return a tupple of values representing the unicity of the object
[ "Return", "a", "tupple", "of", "values", "representing", "the", "unicity", "of", "the", "object" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/object/source_dto.py#L181-L184
SolutionsCloud/apidoc
apidoc/object/source_dto.py
RequestParameter.get_comparable_values_for_ordering
def get_comparable_values_for_ordering(self): """Return a tupple of values representing the unicity of the object """ return (0 if self.position >= 0 else 1, int(self.position), str(self.name), str(self.description))
python
def get_comparable_values_for_ordering(self): """Return a tupple of values representing the unicity of the object """ return (0 if self.position >= 0 else 1, int(self.position), str(self.name), str(self.description))
[ "def", "get_comparable_values_for_ordering", "(", "self", ")", ":", "return", "(", "0", "if", "self", ".", "position", ">=", "0", "else", "1", ",", "int", "(", "self", ".", "position", ")", ",", "str", "(", "self", ".", "name", ")", ",", "str", "(", ...
Return a tupple of values representing the unicity of the object
[ "Return", "a", "tupple", "of", "values", "representing", "the", "unicity", "of", "the", "object" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/object/source_dto.py#L204-L208
SolutionsCloud/apidoc
apidoc/object/source_dto.py
ResponseCode.get_comparable_values
def get_comparable_values(self): """Return a tupple of values representing the unicity of the object """ return (not self.generic, int(self.code), str(self.message), str(self.description))
python
def get_comparable_values(self): """Return a tupple of values representing the unicity of the object """ return (not self.generic, int(self.code), str(self.message), str(self.description))
[ "def", "get_comparable_values", "(", "self", ")", ":", "return", "(", "not", "self", ".", "generic", ",", "int", "(", "self", ".", "code", ")", ",", "str", "(", "self", ".", "message", ")", ",", "str", "(", "self", ".", "description", ")", ")" ]
Return a tupple of values representing the unicity of the object
[ "Return", "a", "tupple", "of", "values", "representing", "the", "unicity", "of", "the", "object" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/object/source_dto.py#L221-L224
SolutionsCloud/apidoc
apidoc/object/source_dto.py
Object.factory
def factory(cls, object_source): """Return a proper object """ if object_source.type is ObjectRaw.Types.object: return ObjectObject(object_source) elif object_source.type not in ObjectRaw.Types or object_source.type is ObjectRaw.Types.type: return ObjectType(objec...
python
def factory(cls, object_source): """Return a proper object """ if object_source.type is ObjectRaw.Types.object: return ObjectObject(object_source) elif object_source.type not in ObjectRaw.Types or object_source.type is ObjectRaw.Types.type: return ObjectType(objec...
[ "def", "factory", "(", "cls", ",", "object_source", ")", ":", "if", "object_source", ".", "type", "is", "ObjectRaw", ".", "Types", ".", "object", ":", "return", "ObjectObject", "(", "object_source", ")", "elif", "object_source", ".", "type", "not", "in", "...
Return a proper object
[ "Return", "a", "proper", "object" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/object/source_dto.py#L273-L289
SolutionsCloud/apidoc
apidoc/object/source_dto.py
Object.get_comparable_values
def get_comparable_values(self): """Return a tupple of values representing the unicity of the object """ return (str(self.name), str(self.description), str(self.type), bool(self.optional), str(self.constraints) if isinstance(self, Constraintable) else "")
python
def get_comparable_values(self): """Return a tupple of values representing the unicity of the object """ return (str(self.name), str(self.description), str(self.type), bool(self.optional), str(self.constraints) if isinstance(self, Constraintable) else "")
[ "def", "get_comparable_values", "(", "self", ")", ":", "return", "(", "str", "(", "self", ".", "name", ")", ",", "str", "(", "self", ".", "description", ")", ",", "str", "(", "self", ".", "type", ")", ",", "bool", "(", "self", ".", "optional", ")",...
Return a tupple of values representing the unicity of the object
[ "Return", "a", "tupple", "of", "values", "representing", "the", "unicity", "of", "the", "object" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/object/source_dto.py#L301-L304
SolutionsCloud/apidoc
apidoc/object/source_dto.py
ObjectEnum.get_comparable_values
def get_comparable_values(self): """Return a tupple of values representing the unicity of the object """ return (str(self.name), str(self.description), str(self.constraints))
python
def get_comparable_values(self): """Return a tupple of values representing the unicity of the object """ return (str(self.name), str(self.description), str(self.constraints))
[ "def", "get_comparable_values", "(", "self", ")", ":", "return", "(", "str", "(", "self", ".", "name", ")", ",", "str", "(", "self", ".", "description", ")", ",", "str", "(", "self", ".", "constraints", ")", ")" ]
Return a tupple of values representing the unicity of the object
[ "Return", "a", "tupple", "of", "values", "representing", "the", "unicity", "of", "the", "object" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/object/source_dto.py#L370-L373
SolutionsCloud/apidoc
apidoc/factory/source/category.py
Category.create_from_name_and_dictionary
def create_from_name_and_dictionary(self, name, datas): """Return a populated object Category from dictionary datas """ category = ObjectCategory(name) self.set_common_datas(category, name, datas) if "order" in datas: category.order = int(datas["order"]) ret...
python
def create_from_name_and_dictionary(self, name, datas): """Return a populated object Category from dictionary datas """ category = ObjectCategory(name) self.set_common_datas(category, name, datas) if "order" in datas: category.order = int(datas["order"]) ret...
[ "def", "create_from_name_and_dictionary", "(", "self", ",", "name", ",", "datas", ")", ":", "category", "=", "ObjectCategory", "(", "name", ")", "self", ".", "set_common_datas", "(", "category", ",", "name", ",", "datas", ")", "if", "\"order\"", "in", "datas...
Return a populated object Category from dictionary datas
[ "Return", "a", "populated", "object", "Category", "from", "dictionary", "datas" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/factory/source/category.py#L10-L19
SolutionsCloud/apidoc
apidoc/service/parser.py
Parser.load_from_file
def load_from_file(self, file_path, format=None): """Return dict from a file config """ if format is None: base_name, file_extension = os.path.splitext(file_path) if file_extension in (".yaml", ".yml"): format = "yaml" elif file_extension in ("...
python
def load_from_file(self, file_path, format=None): """Return dict from a file config """ if format is None: base_name, file_extension = os.path.splitext(file_path) if file_extension in (".yaml", ".yml"): format = "yaml" elif file_extension in ("...
[ "def", "load_from_file", "(", "self", ",", "file_path", ",", "format", "=", "None", ")", ":", "if", "format", "is", "None", ":", "base_name", ",", "file_extension", "=", "os", ".", "path", ".", "splitext", "(", "file_path", ")", "if", "file_extension", "...
Return dict from a file config
[ "Return", "dict", "from", "a", "file", "config" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/service/parser.py#L10-L27
SolutionsCloud/apidoc
apidoc/service/parser.py
Parser.load_all_from_directory
def load_all_from_directory(self, directory_path): """Return a list of dict from a directory containing files """ datas = [] for root, folders, files in os.walk(directory_path): for f in files: datas.append(self.load_from_file(os.path.join(root, f))) ...
python
def load_all_from_directory(self, directory_path): """Return a list of dict from a directory containing files """ datas = [] for root, folders, files in os.walk(directory_path): for f in files: datas.append(self.load_from_file(os.path.join(root, f))) ...
[ "def", "load_all_from_directory", "(", "self", ",", "directory_path", ")", ":", "datas", "=", "[", "]", "for", "root", ",", "folders", ",", "files", "in", "os", ".", "walk", "(", "directory_path", ")", ":", "for", "f", "in", "files", ":", "datas", ".",...
Return a list of dict from a directory containing files
[ "Return", "a", "list", "of", "dict", "from", "a", "directory", "containing", "files" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/service/parser.py#L29-L37
SolutionsCloud/apidoc
apidoc/lib/util/serialize.py
json_repr
def json_repr(obj): """Represent instance of a class as JSON. """ def serialize(obj): """Recursively walk object's hierarchy. """ if obj is None: return None if isinstance(obj, Enum): return str(obj) if isinstance(obj, (bool, int, float, str))...
python
def json_repr(obj): """Represent instance of a class as JSON. """ def serialize(obj): """Recursively walk object's hierarchy. """ if obj is None: return None if isinstance(obj, Enum): return str(obj) if isinstance(obj, (bool, int, float, str))...
[ "def", "json_repr", "(", "obj", ")", ":", "def", "serialize", "(", "obj", ")", ":", "\"\"\"Recursively walk object's hierarchy.\n \"\"\"", "if", "obj", "is", "None", ":", "return", "None", "if", "isinstance", "(", "obj", ",", "Enum", ")", ":", "return",...
Represent instance of a class as JSON.
[ "Represent", "instance", "of", "a", "class", "as", "JSON", "." ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/lib/util/serialize.py#L5-L31
SolutionsCloud/apidoc
apidoc/factory/source/rootDto.py
RootDto.create_from_root
def create_from_root(self, root_source): """Return a populated Object Root from dictionnary datas """ root_dto = ObjectRoot() root_dto.configuration = root_source.configuration root_dto.versions = [Version(x) for x in root_source.versions.values()] for version in sorte...
python
def create_from_root(self, root_source): """Return a populated Object Root from dictionnary datas """ root_dto = ObjectRoot() root_dto.configuration = root_source.configuration root_dto.versions = [Version(x) for x in root_source.versions.values()] for version in sorte...
[ "def", "create_from_root", "(", "self", ",", "root_source", ")", ":", "root_dto", "=", "ObjectRoot", "(", ")", "root_dto", ".", "configuration", "=", "root_source", ".", "configuration", "root_dto", ".", "versions", "=", "[", "Version", "(", "x", ")", "for",...
Return a populated Object Root from dictionnary datas
[ "Return", "a", "populated", "Object", "Root", "from", "dictionnary", "datas" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/factory/source/rootDto.py#L18-L36
SolutionsCloud/apidoc
apidoc/factory/source/element.py
Element.set_common_datas
def set_common_datas(self, element, name, datas): """Populated common data for an element from dictionnary datas """ element.name = str(name) if "description" in datas: element.description = str(datas["description"]).strip() if isinstance(element, Sampleable) and ele...
python
def set_common_datas(self, element, name, datas): """Populated common data for an element from dictionnary datas """ element.name = str(name) if "description" in datas: element.description = str(datas["description"]).strip() if isinstance(element, Sampleable) and ele...
[ "def", "set_common_datas", "(", "self", ",", "element", ",", "name", ",", "datas", ")", ":", "element", ".", "name", "=", "str", "(", "name", ")", "if", "\"description\"", "in", "datas", ":", "element", ".", "description", "=", "str", "(", "datas", "["...
Populated common data for an element from dictionnary datas
[ "Populated", "common", "data", "for", "an", "element", "from", "dictionnary", "datas" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/factory/source/element.py#L12-L29
SolutionsCloud/apidoc
apidoc/factory/source/element.py
Element.create_dictionary_of_element_from_dictionary
def create_dictionary_of_element_from_dictionary(self, property_name, datas): """Populate a dictionary of elements """ response = {} if property_name in datas and datas[property_name] is not None and isinstance(datas[property_name], collections.Iterable): for key, value in da...
python
def create_dictionary_of_element_from_dictionary(self, property_name, datas): """Populate a dictionary of elements """ response = {} if property_name in datas and datas[property_name] is not None and isinstance(datas[property_name], collections.Iterable): for key, value in da...
[ "def", "create_dictionary_of_element_from_dictionary", "(", "self", ",", "property_name", ",", "datas", ")", ":", "response", "=", "{", "}", "if", "property_name", "in", "datas", "and", "datas", "[", "property_name", "]", "is", "not", "None", "and", "isinstance"...
Populate a dictionary of elements
[ "Populate", "a", "dictionary", "of", "elements" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/factory/source/element.py#L31-L39
SolutionsCloud/apidoc
apidoc/factory/source/element.py
Element.create_list_of_element_from_dictionary
def create_list_of_element_from_dictionary(self, property_name, datas): """Populate a list of elements """ response = [] if property_name in datas and datas[property_name] is not None and isinstance(datas[property_name], list): for value in datas[property_name]: ...
python
def create_list_of_element_from_dictionary(self, property_name, datas): """Populate a list of elements """ response = [] if property_name in datas and datas[property_name] is not None and isinstance(datas[property_name], list): for value in datas[property_name]: ...
[ "def", "create_list_of_element_from_dictionary", "(", "self", ",", "property_name", ",", "datas", ")", ":", "response", "=", "[", "]", "if", "property_name", "in", "datas", "and", "datas", "[", "property_name", "]", "is", "not", "None", "and", "isinstance", "(...
Populate a list of elements
[ "Populate", "a", "list", "of", "elements" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/factory/source/element.py#L41-L49
SolutionsCloud/apidoc
apidoc/factory/source/element.py
Element.get_enum
def get_enum(self, property, enum, datas): """Factory enum type """ str_property = str(datas[property]).lower() if str_property not in enum: raise ValueError("Unknow enum \"%s\" for \"%s\"." % (str_property, property)) return enum(str_property)
python
def get_enum(self, property, enum, datas): """Factory enum type """ str_property = str(datas[property]).lower() if str_property not in enum: raise ValueError("Unknow enum \"%s\" for \"%s\"." % (str_property, property)) return enum(str_property)
[ "def", "get_enum", "(", "self", ",", "property", ",", "enum", ",", "datas", ")", ":", "str_property", "=", "str", "(", "datas", "[", "property", "]", ")", ".", "lower", "(", ")", "if", "str_property", "not", "in", "enum", ":", "raise", "ValueError", ...
Factory enum type
[ "Factory", "enum", "type" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/factory/source/element.py#L51-L57
SolutionsCloud/apidoc
apidoc/factory/template.py
Template.create_from_config
def create_from_config(self, config): """Create a template object file defined in the config object """ configService = ConfigService() template = TemplateService() template.output = config["output"]["location"] template_file = configService.get_template_from_config(co...
python
def create_from_config(self, config): """Create a template object file defined in the config object """ configService = ConfigService() template = TemplateService() template.output = config["output"]["location"] template_file = configService.get_template_from_config(co...
[ "def", "create_from_config", "(", "self", ",", "config", ")", ":", "configService", "=", "ConfigService", "(", ")", "template", "=", "TemplateService", "(", ")", "template", ".", "output", "=", "config", "[", "\"output\"", "]", "[", "\"location\"", "]", "tem...
Create a template object file defined in the config object
[ "Create", "a", "template", "object", "file", "defined", "in", "the", "config", "object" ]
train
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/factory/template.py#L12-L25
globocom/GloboNetworkAPI-client-python
networkapiclient/ApiNetworkIPv4.py
ApiNetworkIPv4.deploy
def deploy(self, id_networkv4): """Deploy network in equipments and set column 'active = 1' in tables redeipv4 :param id_networkv4: ID for NetworkIPv4 :return: Equipments configuration output """ data = dict() uri = 'api/networkv4/%s/equipments/' % id_networkv4 ...
python
def deploy(self, id_networkv4): """Deploy network in equipments and set column 'active = 1' in tables redeipv4 :param id_networkv4: ID for NetworkIPv4 :return: Equipments configuration output """ data = dict() uri = 'api/networkv4/%s/equipments/' % id_networkv4 ...
[ "def", "deploy", "(", "self", ",", "id_networkv4", ")", ":", "data", "=", "dict", "(", ")", "uri", "=", "'api/networkv4/%s/equipments/'", "%", "id_networkv4", "return", "super", "(", "ApiNetworkIPv4", ",", "self", ")", ".", "post", "(", "uri", ",", "data",...
Deploy network in equipments and set column 'active = 1' in tables redeipv4 :param id_networkv4: ID for NetworkIPv4 :return: Equipments configuration output
[ "Deploy", "network", "in", "equipments", "and", "set", "column", "active", "=", "1", "in", "tables", "redeipv4" ]
train
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiNetworkIPv4.py#L22-L33
globocom/GloboNetworkAPI-client-python
networkapiclient/ApiNetworkIPv4.py
ApiNetworkIPv4.get_by_id
def get_by_id(self, id_networkv4): """Get IPv4 network :param id_networkv4: ID for NetworkIPv4 :return: IPv4 Network """ uri = 'api/networkv4/%s/' % id_networkv4 return super(ApiNetworkIPv4, self).get(uri)
python
def get_by_id(self, id_networkv4): """Get IPv4 network :param id_networkv4: ID for NetworkIPv4 :return: IPv4 Network """ uri = 'api/networkv4/%s/' % id_networkv4 return super(ApiNetworkIPv4, self).get(uri)
[ "def", "get_by_id", "(", "self", ",", "id_networkv4", ")", ":", "uri", "=", "'api/networkv4/%s/'", "%", "id_networkv4", "return", "super", "(", "ApiNetworkIPv4", ",", "self", ")", ".", "get", "(", "uri", ")" ]
Get IPv4 network :param id_networkv4: ID for NetworkIPv4 :return: IPv4 Network
[ "Get", "IPv4", "network" ]
train
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiNetworkIPv4.py#L35-L45
globocom/GloboNetworkAPI-client-python
networkapiclient/ApiNetworkIPv4.py
ApiNetworkIPv4.list
def list(self, environment_vip=None): """List IPv4 networks :param environment_vip: environment vip to filter :return: IPv4 Networks """ uri = 'api/networkv4/?' if environment_vip: uri += 'environment_vip=%s' % environment_vip return super(ApiNetwo...
python
def list(self, environment_vip=None): """List IPv4 networks :param environment_vip: environment vip to filter :return: IPv4 Networks """ uri = 'api/networkv4/?' if environment_vip: uri += 'environment_vip=%s' % environment_vip return super(ApiNetwo...
[ "def", "list", "(", "self", ",", "environment_vip", "=", "None", ")", ":", "uri", "=", "'api/networkv4/?'", "if", "environment_vip", ":", "uri", "+=", "'environment_vip=%s'", "%", "environment_vip", "return", "super", "(", "ApiNetworkIPv4", ",", "self", ")", "...
List IPv4 networks :param environment_vip: environment vip to filter :return: IPv4 Networks
[ "List", "IPv4", "networks" ]
train
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiNetworkIPv4.py#L47-L59
globocom/GloboNetworkAPI-client-python
networkapiclient/ApiNetworkIPv4.py
ApiNetworkIPv4.undeploy
def undeploy(self, id_networkv4): """Remove deployment of network in equipments and set column 'active = 0' in tables redeipv4 ] :param id_networkv4: ID for NetworkIPv4 :return: Equipments configuration output """ uri = 'api/networkv4/%s/equipments/' % id_networkv4 re...
python
def undeploy(self, id_networkv4): """Remove deployment of network in equipments and set column 'active = 0' in tables redeipv4 ] :param id_networkv4: ID for NetworkIPv4 :return: Equipments configuration output """ uri = 'api/networkv4/%s/equipments/' % id_networkv4 re...
[ "def", "undeploy", "(", "self", ",", "id_networkv4", ")", ":", "uri", "=", "'api/networkv4/%s/equipments/'", "%", "id_networkv4", "return", "super", "(", "ApiNetworkIPv4", ",", "self", ")", ".", "delete", "(", "uri", ")" ]
Remove deployment of network in equipments and set column 'active = 0' in tables redeipv4 ] :param id_networkv4: ID for NetworkIPv4 :return: Equipments configuration output
[ "Remove", "deployment", "of", "network", "in", "equipments", "and", "set", "column", "active", "=", "0", "in", "tables", "redeipv4", "]" ]
train
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiNetworkIPv4.py#L61-L71
globocom/GloboNetworkAPI-client-python
networkapiclient/ApiNetworkIPv4.py
ApiNetworkIPv4.check_vip_ip
def check_vip_ip(self, ip, environment_vip): """ Check available ip in environment vip """ uri = 'api/ipv4/ip/%s/environment-vip/%s/' % (ip, environment_vip) return super(ApiNetworkIPv4, self).get(uri)
python
def check_vip_ip(self, ip, environment_vip): """ Check available ip in environment vip """ uri = 'api/ipv4/ip/%s/environment-vip/%s/' % (ip, environment_vip) return super(ApiNetworkIPv4, self).get(uri)
[ "def", "check_vip_ip", "(", "self", ",", "ip", ",", "environment_vip", ")", ":", "uri", "=", "'api/ipv4/ip/%s/environment-vip/%s/'", "%", "(", "ip", ",", "environment_vip", ")", "return", "super", "(", "ApiNetworkIPv4", ",", "self", ")", ".", "get", "(", "ur...
Check available ip in environment vip
[ "Check", "available", "ip", "in", "environment", "vip" ]
train
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiNetworkIPv4.py#L73-L79
globocom/GloboNetworkAPI-client-python
networkapiclient/ApiNetworkIPv4.py
ApiNetworkIPv4.delete_ipv4
def delete_ipv4(self, ipv4_id): """ Delete ipv4 """ uri = 'api/ipv4/%s/' % (ipv4_id) return super(ApiNetworkIPv4, self).delete(uri)
python
def delete_ipv4(self, ipv4_id): """ Delete ipv4 """ uri = 'api/ipv4/%s/' % (ipv4_id) return super(ApiNetworkIPv4, self).delete(uri)
[ "def", "delete_ipv4", "(", "self", ",", "ipv4_id", ")", ":", "uri", "=", "'api/ipv4/%s/'", "%", "(", "ipv4_id", ")", "return", "super", "(", "ApiNetworkIPv4", ",", "self", ")", ".", "delete", "(", "uri", ")" ]
Delete ipv4
[ "Delete", "ipv4" ]
train
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiNetworkIPv4.py#L81-L87
globocom/GloboNetworkAPI-client-python
networkapiclient/ApiNetworkIPv4.py
ApiNetworkIPv4.search
def search(self, **kwargs): """ Method to search ipv4's based on extends search. :param search: Dict containing QuerySets to find ipv4's. :param include: Array containing fields to include on response. :param exclude: Array containing fields to exclude on response. :para...
python
def search(self, **kwargs): """ Method to search ipv4's based on extends search. :param search: Dict containing QuerySets to find ipv4's. :param include: Array containing fields to include on response. :param exclude: Array containing fields to exclude on response. :para...
[ "def", "search", "(", "self", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "ApiNetworkIPv4", ",", "self", ")", ".", "get", "(", "self", ".", "prepare_url", "(", "'api/v3/networkv4/'", ",", "kwargs", ")", ")" ]
Method to search ipv4's based on extends search. :param search: Dict containing QuerySets to find ipv4's. :param include: Array containing fields to include on response. :param exclude: Array containing fields to exclude on response. :param fields: Array containing fields to override d...
[ "Method", "to", "search", "ipv4", "s", "based", "on", "extends", "search", "." ]
train
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiNetworkIPv4.py#L89-L102
globocom/GloboNetworkAPI-client-python
networkapiclient/ApiNetworkIPv4.py
ApiNetworkIPv4.delete
def delete(self, ids): """ Method to delete network-ipv4's by their ids :param ids: Identifiers of network-ipv4's :return: None """ url = build_uri_with_ids('api/v3/networkv4/%s/', ids) return super(ApiNetworkIPv4, self).delete(url)
python
def delete(self, ids): """ Method to delete network-ipv4's by their ids :param ids: Identifiers of network-ipv4's :return: None """ url = build_uri_with_ids('api/v3/networkv4/%s/', ids) return super(ApiNetworkIPv4, self).delete(url)
[ "def", "delete", "(", "self", ",", "ids", ")", ":", "url", "=", "build_uri_with_ids", "(", "'api/v3/networkv4/%s/'", ",", "ids", ")", "return", "super", "(", "ApiNetworkIPv4", ",", "self", ")", ".", "delete", "(", "url", ")" ]
Method to delete network-ipv4's by their ids :param ids: Identifiers of network-ipv4's :return: None
[ "Method", "to", "delete", "network", "-", "ipv4", "s", "by", "their", "ids" ]
train
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiNetworkIPv4.py#L119-L128
globocom/GloboNetworkAPI-client-python
networkapiclient/ApiNetworkIPv4.py
ApiNetworkIPv4.update
def update(self, networkipv4s): """ Method to update network-ipv4's :param networkipv4s: List containing network-ipv4's desired to updated :return: None """ data = {'networks': networkipv4s} networkipv4s_ids = [str(networkipv4.get('id')) ...
python
def update(self, networkipv4s): """ Method to update network-ipv4's :param networkipv4s: List containing network-ipv4's desired to updated :return: None """ data = {'networks': networkipv4s} networkipv4s_ids = [str(networkipv4.get('id')) ...
[ "def", "update", "(", "self", ",", "networkipv4s", ")", ":", "data", "=", "{", "'networks'", ":", "networkipv4s", "}", "networkipv4s_ids", "=", "[", "str", "(", "networkipv4", ".", "get", "(", "'id'", ")", ")", "for", "networkipv4", "in", "networkipv4s", ...
Method to update network-ipv4's :param networkipv4s: List containing network-ipv4's desired to updated :return: None
[ "Method", "to", "update", "network", "-", "ipv4", "s" ]
train
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiNetworkIPv4.py#L130-L143
globocom/GloboNetworkAPI-client-python
networkapiclient/ApiNetworkIPv4.py
ApiNetworkIPv4.create
def create(self, networkipv4s): """ Method to create network-ipv4's :param networkipv4s: List containing networkipv4's desired to be created on database :return: None """ data = {'networks': networkipv4s} return super(ApiNetworkIPv4, self).post('api/v3/networkv4...
python
def create(self, networkipv4s): """ Method to create network-ipv4's :param networkipv4s: List containing networkipv4's desired to be created on database :return: None """ data = {'networks': networkipv4s} return super(ApiNetworkIPv4, self).post('api/v3/networkv4...
[ "def", "create", "(", "self", ",", "networkipv4s", ")", ":", "data", "=", "{", "'networks'", ":", "networkipv4s", "}", "return", "super", "(", "ApiNetworkIPv4", ",", "self", ")", ".", "post", "(", "'api/v3/networkv4/'", ",", "data", ")" ]
Method to create network-ipv4's :param networkipv4s: List containing networkipv4's desired to be created on database :return: None
[ "Method", "to", "create", "network", "-", "ipv4", "s" ]
train
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiNetworkIPv4.py#L145-L154
globocom/GloboNetworkAPI-client-python
networkapiclient/DivisaoDc.py
DivisaoDc.inserir
def inserir(self, name): """Inserts a new Division Dc and returns its identifier. :param name: Division Dc name. String with a minimum 2 and maximum of 80 characters :return: Dictionary with the following structure: :: {'division_dc': {'id': < id_division_dc >}} ...
python
def inserir(self, name): """Inserts a new Division Dc and returns its identifier. :param name: Division Dc name. String with a minimum 2 and maximum of 80 characters :return: Dictionary with the following structure: :: {'division_dc': {'id': < id_division_dc >}} ...
[ "def", "inserir", "(", "self", ",", "name", ")", ":", "division_dc_map", "=", "dict", "(", ")", "division_dc_map", "[", "'name'", "]", "=", "name", "code", ",", "xml", "=", "self", ".", "submit", "(", "{", "'division_dc'", ":", "division_dc_map", "}", ...
Inserts a new Division Dc and returns its identifier. :param name: Division Dc name. String with a minimum 2 and maximum of 80 characters :return: Dictionary with the following structure: :: {'division_dc': {'id': < id_division_dc >}} :raise InvalidParameterError: Name i...
[ "Inserts", "a", "new", "Division", "Dc", "and", "returns", "its", "identifier", "." ]
train
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/DivisaoDc.py#L58-L81
globocom/GloboNetworkAPI-client-python
networkapiclient/DivisaoDc.py
DivisaoDc.alterar
def alterar(self, id_divisiondc, name): """Change Division Dc from by the identifier. :param id_divisiondc: Identifier of the Division Dc. Integer value and greater than zero. :param name: Division Dc name. String with a minimum 2 and maximum of 80 characters :return: None :ra...
python
def alterar(self, id_divisiondc, name): """Change Division Dc from by the identifier. :param id_divisiondc: Identifier of the Division Dc. Integer value and greater than zero. :param name: Division Dc name. String with a minimum 2 and maximum of 80 characters :return: None :ra...
[ "def", "alterar", "(", "self", ",", "id_divisiondc", ",", "name", ")", ":", "if", "not", "is_valid_int_param", "(", "id_divisiondc", ")", ":", "raise", "InvalidParameterError", "(", "u'The identifier of Division Dc is invalid or was not informed.'", ")", "url", "=", "...
Change Division Dc from by the identifier. :param id_divisiondc: Identifier of the Division Dc. Integer value and greater than zero. :param name: Division Dc name. String with a minimum 2 and maximum of 80 characters :return: None :raise InvalidParameterError: The identifier of Divisi...
[ "Change", "Division", "Dc", "from", "by", "the", "identifier", "." ]
train
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/DivisaoDc.py#L83-L109
globocom/GloboNetworkAPI-client-python
networkapiclient/DivisaoDc.py
DivisaoDc.remover
def remover(self, id_divisiondc): """Remove Division Dc from by the identifier. :param id_divisiondc: Identifier of the Division Dc. Integer value and greater than zero. :return: None :raise InvalidParameterError: The identifier of Division Dc is null and invalid. :raise Divis...
python
def remover(self, id_divisiondc): """Remove Division Dc from by the identifier. :param id_divisiondc: Identifier of the Division Dc. Integer value and greater than zero. :return: None :raise InvalidParameterError: The identifier of Division Dc is null and invalid. :raise Divis...
[ "def", "remover", "(", "self", ",", "id_divisiondc", ")", ":", "if", "not", "is_valid_int_param", "(", "id_divisiondc", ")", ":", "raise", "InvalidParameterError", "(", "u'The identifier of Division Dc is invalid or was not informed.'", ")", "url", "=", "'divisiondc/'", ...
Remove Division Dc from by the identifier. :param id_divisiondc: Identifier of the Division Dc. Integer value and greater than zero. :return: None :raise InvalidParameterError: The identifier of Division Dc is null and invalid. :raise DivisaoDcNaoExisteError: Division Dc not registere...
[ "Remove", "Division", "Dc", "from", "by", "the", "identifier", "." ]
train
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/DivisaoDc.py#L111-L132
globocom/GloboNetworkAPI-client-python
networkapiclient/ApiObjectType.py
ApiObjectType.search
def search(self, **kwargs): """ Method to search object types based on extends search. :param search: Dict containing QuerySets to find object types. :param include: Array containing fields to include on response. :param exclude: Array containing fields to exclude on response. ...
python
def search(self, **kwargs): """ Method to search object types based on extends search. :param search: Dict containing QuerySets to find object types. :param include: Array containing fields to include on response. :param exclude: Array containing fields to exclude on response. ...
[ "def", "search", "(", "self", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "ApiObjectType", ",", "self", ")", ".", "get", "(", "self", ".", "prepare_url", "(", "'api/v3/object-type/'", ",", "kwargs", ")", ")" ]
Method to search object types based on extends search. :param search: Dict containing QuerySets to find object types. :param include: Array containing fields to include on response. :param exclude: Array containing fields to exclude on response. :param fields: Array containing fields t...
[ "Method", "to", "search", "object", "types", "based", "on", "extends", "search", "." ]
train
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiObjectType.py#L36-L49
globocom/GloboNetworkAPI-client-python
networkapiclient/Vlan.py
Vlan.find_vlans
def find_vlans( self, number, name, iexact, environment, net_type, network, ip_version, subnet, acl, pagination): """ Find vlans by all search parameters :param nu...
python
def find_vlans( self, number, name, iexact, environment, net_type, network, ip_version, subnet, acl, pagination): """ Find vlans by all search parameters :param nu...
[ "def", "find_vlans", "(", "self", ",", "number", ",", "name", ",", "iexact", ",", "environment", ",", "net_type", ",", "network", ",", "ip_version", ",", "subnet", ",", "acl", ",", "pagination", ")", ":", "if", "not", "isinstance", "(", "pagination", ","...
Find vlans by all search parameters :param number: Filter by vlan number column :param name: Filter by vlan name column :param iexact: Filter by name will be exact? :param environment: Filter by environment ID related :param net_type: Filter by network_type ID related :p...
[ "Find", "vlans", "by", "all", "search", "parameters" ]
train
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Vlan.py#L84-L164
globocom/GloboNetworkAPI-client-python
networkapiclient/Vlan.py
Vlan.listar_por_ambiente
def listar_por_ambiente(self, id_ambiente): """List all VLANs from an environment. ** The itens returning from network is there to be compatible with other system ** :param id_ambiente: Environment identifier. :return: Following dictionary: :: {'vlan': [{'id': < id_v...
python
def listar_por_ambiente(self, id_ambiente): """List all VLANs from an environment. ** The itens returning from network is there to be compatible with other system ** :param id_ambiente: Environment identifier. :return: Following dictionary: :: {'vlan': [{'id': < id_v...
[ "def", "listar_por_ambiente", "(", "self", ",", "id_ambiente", ")", ":", "if", "not", "is_valid_int_param", "(", "id_ambiente", ")", ":", "raise", "InvalidParameterError", "(", "u'Environment id is none or invalid.'", ")", "url", "=", "'vlan/ambiente/'", "+", "str", ...
List all VLANs from an environment. ** The itens returning from network is there to be compatible with other system ** :param id_ambiente: Environment identifier. :return: Following dictionary: :: {'vlan': [{'id': < id_vlan >, 'nome': < nome_vlan >, 'num_...
[ "List", "all", "VLANs", "from", "an", "environment", ".", "**", "The", "itens", "returning", "from", "network", "is", "there", "to", "be", "compatible", "with", "other", "system", "**", ":", "param", "id_ambiente", ":", "Environment", "identifier", "." ]
train
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Vlan.py#L189-L232
globocom/GloboNetworkAPI-client-python
networkapiclient/Vlan.py
Vlan.alocar
def alocar( self, nome, id_tipo_rede, id_ambiente, descricao, id_ambiente_vip=None, vrf=None): """Inserts a new VLAN. :param nome: Name of Vlan. String with a maximum of 50 characters. :param id_tipo_rede: Ident...
python
def alocar( self, nome, id_tipo_rede, id_ambiente, descricao, id_ambiente_vip=None, vrf=None): """Inserts a new VLAN. :param nome: Name of Vlan. String with a maximum of 50 characters. :param id_tipo_rede: Ident...
[ "def", "alocar", "(", "self", ",", "nome", ",", "id_tipo_rede", ",", "id_ambiente", ",", "descricao", ",", "id_ambiente_vip", "=", "None", ",", "vrf", "=", "None", ")", ":", "vlan_map", "=", "dict", "(", ")", "vlan_map", "[", "'nome'", "]", "=", "nome"...
Inserts a new VLAN. :param nome: Name of Vlan. String with a maximum of 50 characters. :param id_tipo_rede: Identifier of the Network Type. Integer value and greater than zero. :param id_ambiente: Identifier of the Environment. Integer value and greater than zero. :param descricao: Desc...
[ "Inserts", "a", "new", "VLAN", "." ]
train
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Vlan.py#L234-L296
globocom/GloboNetworkAPI-client-python
networkapiclient/Vlan.py
Vlan.insert_vlan
def insert_vlan( self, environment_id, name, number, description, acl_file, acl_file_v6, network_ipv4, network_ipv6, vrf=None): """Create new VLAN :param environment_id: ID for Enviro...
python
def insert_vlan( self, environment_id, name, number, description, acl_file, acl_file_v6, network_ipv4, network_ipv6, vrf=None): """Create new VLAN :param environment_id: ID for Enviro...
[ "def", "insert_vlan", "(", "self", ",", "environment_id", ",", "name", ",", "number", ",", "description", ",", "acl_file", ",", "acl_file_v6", ",", "network_ipv4", ",", "network_ipv6", ",", "vrf", "=", "None", ")", ":", "if", "not", "is_valid_int_param", "("...
Create new VLAN :param environment_id: ID for Environment. :param name: The name of VLAN. :param description: Some description to VLAN. :param number: Number of Vlan :param acl_file: Acl IPv4 File name to VLAN. :param acl_file_v6: Acl IPv6 File name to VLAN. :par...
[ "Create", "new", "VLAN" ]
train
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Vlan.py#L298-L362
globocom/GloboNetworkAPI-client-python
networkapiclient/Vlan.py
Vlan.edit_vlan
def edit_vlan( self, environment_id, name, number, description, acl_file, acl_file_v6, id_vlan): """Edit a VLAN :param id_vlan: ID for Vlan :param environment_id: ID for Environment. :param n...
python
def edit_vlan( self, environment_id, name, number, description, acl_file, acl_file_v6, id_vlan): """Edit a VLAN :param id_vlan: ID for Vlan :param environment_id: ID for Environment. :param n...
[ "def", "edit_vlan", "(", "self", ",", "environment_id", ",", "name", ",", "number", ",", "description", ",", "acl_file", ",", "acl_file_v6", ",", "id_vlan", ")", ":", "if", "not", "is_valid_int_param", "(", "id_vlan", ")", ":", "raise", "InvalidParameterError"...
Edit a VLAN :param id_vlan: ID for Vlan :param environment_id: ID for Environment. :param name: The name of VLAN. :param description: Some description to VLAN. :param number: Number of Vlan :param acl_file: Acl IPv4 File name to VLAN. :param acl_file_v6: Acl IPv6...
[ "Edit", "a", "VLAN" ]
train
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Vlan.py#L364-L414
globocom/GloboNetworkAPI-client-python
networkapiclient/Vlan.py
Vlan.create_vlan
def create_vlan(self, id_vlan): """ Set column 'ativada = 1'. :param id_vlan: VLAN identifier. :return: None """ vlan_map = dict() vlan_map['vlan_id'] = id_vlan code, xml = self.submit({'vlan': vlan_map}, 'PUT', 'vlan/create/') return self.response(c...
python
def create_vlan(self, id_vlan): """ Set column 'ativada = 1'. :param id_vlan: VLAN identifier. :return: None """ vlan_map = dict() vlan_map['vlan_id'] = id_vlan code, xml = self.submit({'vlan': vlan_map}, 'PUT', 'vlan/create/') return self.response(c...
[ "def", "create_vlan", "(", "self", ",", "id_vlan", ")", ":", "vlan_map", "=", "dict", "(", ")", "vlan_map", "[", "'vlan_id'", "]", "=", "id_vlan", "code", ",", "xml", "=", "self", ".", "submit", "(", "{", "'vlan'", ":", "vlan_map", "}", ",", "'PUT'",...
Set column 'ativada = 1'. :param id_vlan: VLAN identifier. :return: None
[ "Set", "column", "ativada", "=", "1", "." ]
train
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Vlan.py#L416-L430
globocom/GloboNetworkAPI-client-python
networkapiclient/Vlan.py
Vlan.allocate_without_network
def allocate_without_network(self, environment_id, name, description, vrf=None): """Create new VLAN without add NetworkIPv4. :param environment_id: ID for Environment. :param name: The name of VLAN. :param description: Some description to VLAN. :return: Following dictionary: ...
python
def allocate_without_network(self, environment_id, name, description, vrf=None): """Create new VLAN without add NetworkIPv4. :param environment_id: ID for Environment. :param name: The name of VLAN. :param description: Some description to VLAN. :return: Following dictionary: ...
[ "def", "allocate_without_network", "(", "self", ",", "environment_id", ",", "name", ",", "description", ",", "vrf", "=", "None", ")", ":", "vlan_map", "=", "dict", "(", ")", "vlan_map", "[", "'environment_id'", "]", "=", "environment_id", "vlan_map", "[", "'...
Create new VLAN without add NetworkIPv4. :param environment_id: ID for Environment. :param name: The name of VLAN. :param description: Some description to VLAN. :return: Following dictionary: :: {'vlan': {'id': < id_vlan >, 'nome': < nome_vlan >, ...
[ "Create", "new", "VLAN", "without", "add", "NetworkIPv4", "." ]
train
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Vlan.py#L432-L468
globocom/GloboNetworkAPI-client-python
networkapiclient/Vlan.py
Vlan.verificar_permissao
def verificar_permissao(self, id_vlan, nome_equipamento, nome_interface): """Check if there is communication permission for VLAN to trunk. Run script 'configurador'. The "stdout" key value of response dictionary is 1(one) if VLAN has permission, or 0(zero), otherwise. :param i...
python
def verificar_permissao(self, id_vlan, nome_equipamento, nome_interface): """Check if there is communication permission for VLAN to trunk. Run script 'configurador'. The "stdout" key value of response dictionary is 1(one) if VLAN has permission, or 0(zero), otherwise. :param i...
[ "def", "verificar_permissao", "(", "self", ",", "id_vlan", ",", "nome_equipamento", ",", "nome_interface", ")", ":", "if", "not", "is_valid_int_param", "(", "id_vlan", ")", ":", "raise", "InvalidParameterError", "(", "u'Vlan id is invalid or was not informed.'", ")", ...
Check if there is communication permission for VLAN to trunk. Run script 'configurador'. The "stdout" key value of response dictionary is 1(one) if VLAN has permission, or 0(zero), otherwise. :param id_vlan: VLAN identifier. :param nome_equipamento: Equipment name. :pa...
[ "Check", "if", "there", "is", "communication", "permission", "for", "VLAN", "to", "trunk", "." ]
train
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Vlan.py#L554-L596
globocom/GloboNetworkAPI-client-python
networkapiclient/Vlan.py
Vlan.buscar
def buscar(self, id_vlan): """Get VLAN by its identifier. :param id_vlan: VLAN identifier. :return: Following dictionary: :: {'vlan': {'id': < id_vlan >, 'nome': < nome_vlan >, 'num_vlan': < num_vlan >, 'id_ambiente': < id_ambiente >, ...
python
def buscar(self, id_vlan): """Get VLAN by its identifier. :param id_vlan: VLAN identifier. :return: Following dictionary: :: {'vlan': {'id': < id_vlan >, 'nome': < nome_vlan >, 'num_vlan': < num_vlan >, 'id_ambiente': < id_ambiente >, ...
[ "def", "buscar", "(", "self", ",", "id_vlan", ")", ":", "if", "not", "is_valid_int_param", "(", "id_vlan", ")", ":", "raise", "InvalidParameterError", "(", "u'Vlan id is invalid or was not informed.'", ")", "url", "=", "'vlan/'", "+", "str", "(", "id_vlan", ")",...
Get VLAN by its identifier. :param id_vlan: VLAN identifier. :return: Following dictionary: :: {'vlan': {'id': < id_vlan >, 'nome': < nome_vlan >, 'num_vlan': < num_vlan >, 'id_ambiente': < id_ambiente >, 'id_tipo_rede': < id_tipo_rede >, ...
[ "Get", "VLAN", "by", "its", "identifier", "." ]
train
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Vlan.py#L598-L669
globocom/GloboNetworkAPI-client-python
networkapiclient/Vlan.py
Vlan.get
def get(self, id_vlan): """Get a VLAN by your primary key. Network IPv4/IPv6 related will also be fetched. :param id_vlan: ID for VLAN. :return: Following dictionary: :: {'vlan': {'id': < id_vlan >, 'nome': < nome_vlan >, 'num_vlan': < num_vlan >...
python
def get(self, id_vlan): """Get a VLAN by your primary key. Network IPv4/IPv6 related will also be fetched. :param id_vlan: ID for VLAN. :return: Following dictionary: :: {'vlan': {'id': < id_vlan >, 'nome': < nome_vlan >, 'num_vlan': < num_vlan >...
[ "def", "get", "(", "self", ",", "id_vlan", ")", ":", "if", "not", "is_valid_int_param", "(", "id_vlan", ")", ":", "raise", "InvalidParameterError", "(", "u'Parameter id_vlan is invalid. Value: '", "+", "id_vlan", ")", "url", "=", "'vlan/'", "+", "str", "(", "i...
Get a VLAN by your primary key. Network IPv4/IPv6 related will also be fetched. :param id_vlan: ID for VLAN. :return: Following dictionary: :: {'vlan': {'id': < id_vlan >, 'nome': < nome_vlan >, 'num_vlan': < num_vlan >, 'id_ambiente': < id_amb...
[ "Get", "a", "VLAN", "by", "your", "primary", "key", ".", "Network", "IPv4", "/", "IPv6", "related", "will", "also", "be", "fetched", "." ]
train
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Vlan.py#L671-L711
globocom/GloboNetworkAPI-client-python
networkapiclient/Vlan.py
Vlan.listar_permissao
def listar_permissao(self, nome_equipamento, nome_interface): """List all VLANS having communication permission to trunk from a port in switch. Run script 'configurador'. :: The value of 'stdout' key of return dictionary can have a list of numbers or number intervals of VL...
python
def listar_permissao(self, nome_equipamento, nome_interface): """List all VLANS having communication permission to trunk from a port in switch. Run script 'configurador'. :: The value of 'stdout' key of return dictionary can have a list of numbers or number intervals of VL...
[ "def", "listar_permissao", "(", "self", ",", "nome_equipamento", ",", "nome_interface", ")", ":", "vlan_map", "=", "dict", "(", ")", "vlan_map", "[", "'nome'", "]", "=", "nome_equipamento", "vlan_map", "[", "'nome_interface'", "]", "=", "nome_interface", "code",...
List all VLANS having communication permission to trunk from a port in switch. Run script 'configurador'. :: The value of 'stdout' key of return dictionary can have a list of numbers or number intervals of VLAN´s, comma separated. Examples of possible returns of 'stdout' below: ...
[ "List", "all", "VLANS", "having", "communication", "permission", "to", "trunk", "from", "a", "port", "in", "switch", "." ]
train
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Vlan.py#L713-L752
globocom/GloboNetworkAPI-client-python
networkapiclient/Vlan.py
Vlan.create_ipv4
def create_ipv4(self, id_network_ipv4): """Create VLAN in layer 2 using script 'navlan'. :param id_network_ipv4: NetworkIPv4 ID. :return: Following dictionary: :: {‘sucesso’: {‘codigo’: < codigo >, ‘descricao’: {'stdout':< stdout >, 'stderr':< stderr >}}} ...
python
def create_ipv4(self, id_network_ipv4): """Create VLAN in layer 2 using script 'navlan'. :param id_network_ipv4: NetworkIPv4 ID. :return: Following dictionary: :: {‘sucesso’: {‘codigo’: < codigo >, ‘descricao’: {'stdout':< stdout >, 'stderr':< stderr >}}} ...
[ "def", "create_ipv4", "(", "self", ",", "id_network_ipv4", ")", ":", "url", "=", "'vlan/v4/create/'", "vlan_map", "=", "dict", "(", ")", "vlan_map", "[", "'id_network_ip'", "]", "=", "id_network_ipv4", "code", ",", "xml", "=", "self", ".", "submit", "(", "...
Create VLAN in layer 2 using script 'navlan'. :param id_network_ipv4: NetworkIPv4 ID. :return: Following dictionary: :: {‘sucesso’: {‘codigo’: < codigo >, ‘descricao’: {'stdout':< stdout >, 'stderr':< stderr >}}} :raise NetworkIPv4NaoExisteError: NetworkIPv4 not ...
[ "Create", "VLAN", "in", "layer", "2", "using", "script", "navlan", "." ]
train
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Vlan.py#L786-L815
globocom/GloboNetworkAPI-client-python
networkapiclient/Vlan.py
Vlan.create_ipv6
def create_ipv6(self, id_network_ipv6): """Create VLAN in layer 2 using script 'navlan'. :param id_network_ipv6: NetworkIPv6 ID. :return: Following dictionary: :: {‘sucesso’: {‘codigo’: < codigo >, ‘descricao’: {'stdout':< stdout >, 'stderr':< stderr >}}} ...
python
def create_ipv6(self, id_network_ipv6): """Create VLAN in layer 2 using script 'navlan'. :param id_network_ipv6: NetworkIPv6 ID. :return: Following dictionary: :: {‘sucesso’: {‘codigo’: < codigo >, ‘descricao’: {'stdout':< stdout >, 'stderr':< stderr >}}} ...
[ "def", "create_ipv6", "(", "self", ",", "id_network_ipv6", ")", ":", "url", "=", "'vlan/v6/create/'", "vlan_map", "=", "dict", "(", ")", "vlan_map", "[", "'id_network_ip'", "]", "=", "id_network_ipv6", "code", ",", "xml", "=", "self", ".", "submit", "(", "...
Create VLAN in layer 2 using script 'navlan'. :param id_network_ipv6: NetworkIPv6 ID. :return: Following dictionary: :: {‘sucesso’: {‘codigo’: < codigo >, ‘descricao’: {'stdout':< stdout >, 'stderr':< stderr >}}} :raise NetworkIPv6NaoExisteError: NetworkIPv6 not ...
[ "Create", "VLAN", "in", "layer", "2", "using", "script", "navlan", "." ]
train
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Vlan.py#L817-L846
globocom/GloboNetworkAPI-client-python
networkapiclient/Vlan.py
Vlan.apply_acl
def apply_acl(self, equipments, vlan, environment, network): '''Apply the file acl in equipments :param equipments: list of equipments :param vlan: Vvlan :param environment: Environment :param network: v4 or v6 :raise Exception: Failed to apply acl :return: Tru...
python
def apply_acl(self, equipments, vlan, environment, network): '''Apply the file acl in equipments :param equipments: list of equipments :param vlan: Vvlan :param environment: Environment :param network: v4 or v6 :raise Exception: Failed to apply acl :return: Tru...
[ "def", "apply_acl", "(", "self", ",", "equipments", ",", "vlan", ",", "environment", ",", "network", ")", ":", "vlan_map", "=", "dict", "(", ")", "vlan_map", "[", "'equipments'", "]", "=", "equipments", "vlan_map", "[", "'vlan'", "]", "=", "vlan", "vlan_...
Apply the file acl in equipments :param equipments: list of equipments :param vlan: Vvlan :param environment: Environment :param network: v4 or v6 :raise Exception: Failed to apply acl :return: True case Apply and sysout of script
[ "Apply", "the", "file", "acl", "in", "equipments" ]
train
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Vlan.py#L848-L871
globocom/GloboNetworkAPI-client-python
networkapiclient/Vlan.py
Vlan.confirm_vlan
def confirm_vlan(self, number_net, id_environment_vlan, ip_version=None): """Checking if the vlan insert need to be confirmed :param number_net: Filter by vlan number column :param id_environment_vlan: Filter by environment ID related :param ip_version: Ip version for checking ...
python
def confirm_vlan(self, number_net, id_environment_vlan, ip_version=None): """Checking if the vlan insert need to be confirmed :param number_net: Filter by vlan number column :param id_environment_vlan: Filter by environment ID related :param ip_version: Ip version for checking ...
[ "def", "confirm_vlan", "(", "self", ",", "number_net", ",", "id_environment_vlan", ",", "ip_version", "=", "None", ")", ":", "url", "=", "'vlan/confirm/'", "+", "str", "(", "number_net", ")", "+", "'/'", "+", "id_environment_vlan", "+", "'/'", "+", "str", ...
Checking if the vlan insert need to be confirmed :param number_net: Filter by vlan number column :param id_environment_vlan: Filter by environment ID related :param ip_version: Ip version for checking :return: True is need confirmation, False if no need :raise AmbienteNaoExist...
[ "Checking", "if", "the", "vlan", "insert", "need", "to", "be", "confirmed" ]
train
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Vlan.py#L873-L893
globocom/GloboNetworkAPI-client-python
networkapiclient/Vlan.py
Vlan.check_number_available
def check_number_available(self, id_environment, num_vlan, id_vlan): """Checking if environment has a number vlan available :param id_environment: Identifier of environment :param num_vlan: Vlan number :param id_vlan: Vlan indentifier (False if inserting a vlan) :return: True i...
python
def check_number_available(self, id_environment, num_vlan, id_vlan): """Checking if environment has a number vlan available :param id_environment: Identifier of environment :param num_vlan: Vlan number :param id_vlan: Vlan indentifier (False if inserting a vlan) :return: True i...
[ "def", "check_number_available", "(", "self", ",", "id_environment", ",", "num_vlan", ",", "id_vlan", ")", ":", "url", "=", "'vlan/check_number_available/'", "+", "str", "(", "id_environment", ")", "+", "'/'", "+", "str", "(", "num_vlan", ")", "+", "'/'", "+...
Checking if environment has a number vlan available :param id_environment: Identifier of environment :param num_vlan: Vlan number :param id_vlan: Vlan indentifier (False if inserting a vlan) :return: True is has number available, False if hasn't :raise AmbienteNaoExisteError: ...
[ "Checking", "if", "environment", "has", "a", "number", "vlan", "available" ]
train
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Vlan.py#L895-L916