nwo
stringlengths
5
106
sha
stringlengths
40
40
path
stringlengths
4
174
language
stringclasses
1 value
identifier
stringlengths
1
140
parameters
stringlengths
0
87.7k
argument_list
stringclasses
1 value
return_statement
stringlengths
0
426k
docstring
stringlengths
0
64.3k
docstring_summary
stringlengths
0
26.3k
docstring_tokens
list
function
stringlengths
18
4.83M
function_tokens
list
url
stringlengths
83
304
securesystemslab/zippy
ff0e84ac99442c2c55fe1d285332cfd4e185e089
zippy/lib-python/3/idlelib/IOBinding.py
python
IOBinding.set_saved
(self, flag)
[]
def set_saved(self, flag): self.editwin.set_saved(flag)
[ "def", "set_saved", "(", "self", ",", "flag", ")", ":", "self", ".", "editwin", ".", "set_saved", "(", "flag", ")" ]
https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/lib-python/3/idlelib/IOBinding.py#L133-L134
pikpikcu/Pentest-Tools-Framework
cd6e6107764a809943dc4e073cde8149c1a2cd03
modules/xsser/build/bdist.linux-armv7l/egg/core/main.py
python
xsser.start_wizard
(self)
Start Wizard Helper
Start Wizard Helper
[ "Start", "Wizard", "Helper" ]
def start_wizard(self): """ Start Wizard Helper """ #step 0: Menu ans1=True ans2=True ans3=True ans4=True ans5=True ans6=True #step 1: Where while ans1: print("""\nA)- Where are your targets?\n [1]- I want to enter the url of my target directly. [2]- I want to enter a list of targets from a .txt file. *[3]- I don't know where are my target(s)... I just want to explore! :-) [e]- Exit/Quit/Abort. """) ans1 = raw_input("Your choice: [1], [2], [3] or [e]xit\n") if ans1 == "1": # from url url = raw_input("Target url (ex: http(s)://target.com): ") if url.startswith("http"): ans1 = None else: print "\n[Error] Your url is not valid!. Try again!" pass elif ans1 == "2": # from file url = raw_input("Path to file (ex: 'targets_list.txt'): ") if url == None: print "\n[Error] Your are not providing a valid file. Try again!" pass else: ans1 = None elif ans1 == "3": # dorking url = "DORKING" ans1 = None elif (ans1 == "e" or ans1 == "E"): print "Closing wizard..." ans1=None ans2=None ans3=None ans4=None ans5=None ans6=None else: print "\nNot valid choice. Try again!" #step 2: How while ans2: print 22*"-" print("""\nB)- How do you want to connect?\n [1]- I want to connect using GET and select some possible vulnerable parameter(s) directly. [2]- I want to connect using POST and select some possible vulnerable parameter(s) directly. [3]- I want to "crawl" all the links of my target(s) to found as much vulnerabilities as possible. *[4]- I don't know how to connect... Just do it! :-) [e]- Exit/Quit/Abort. """) ans2 = raw_input("Your choice: [1], [2], [3], [4] or [e]xit\n") if ans2 == "1": # using GET payload = raw_input("GET payload (ex: '/menu.php?q='): ") if payload == None: print "\n[Error] Your are providing an empty payload. Try again!" pass else: self.user_template_conntype = "GET" ans2 = None elif ans2 == "2": # using POST payload = raw_input("POST payload (ex: 'foo=1&bar='): ") if payload == None: print "\n[Error] Your are providing an empty payload. Try again!" pass else: self.user_template_conntype = "POST" ans2 = None elif ans2 == "3": # crawlering payload = "CRAWLER" ans2 = None elif ans2 == "4": # crawlering payload = "CRAWLER" ans2 = None elif (ans2 == "e" or ans2 == "E"): print "Closing wizard..." ans2=None ans3=None ans4=None ans5=None ans6=None else: print "\nNot valid choice. Try again!" #step 3: Proxy while ans3: print 22*"-" print("""\nC)- Do you want to be 'anonymous'?\n [1]- Yes. I want to use my proxy and apply automatic spoofing methods. [2]- Anonymous?. Yes!!!. I have a TOR proxy ready at: http://127.0.0.1:8118. *[3]- Yes. But I haven't any proxy. :-) [4]- No. It's not a problem for me to connect directly to the target(s). [e]- Exit/Quit. """) ans3 = raw_input("Your choice: [1], [2], [3], [4] or [e]xit\n") if ans3 == "1": # using PROXY + spoofing proxy = raw_input("Enter proxy [http(s)://server:port]: ") ans3 = None elif ans3 == "2": # using TOR + spoofing proxy = 'Using TOR (default: http://127.0.0.1:8118)' proxy = 'http://127.0.0.1:8118' ans3 = None elif ans3 == "3": # only spoofing proxy = 'Proxy: No - Spoofing: Yes' ans3 = None elif ans3 == "4": # no spoofing proxy = 'Proxy: No - Spoofing: No' ans3 = None elif (ans3 == "e" or ans3 == "E"): print "Closing wizard..." ans3=None ans4=None ans5=None ans6=None else: print "\nNot valid choice. Try again!" #step 4: Bypasser(s) while ans4: print 22*"-" print("""\nD)- Which 'bypasser(s' do you want to use?\n [1]- I want to inject XSS scripts without any encoding. [2]- Try to inject code using 'Hexadecimal'. [3]- Try to inject code mixing 'String.FromCharCode()' and 'Unescape()'. [4]- I want to inject using 'Character Encoding Mutations' (Une+Str+Hex). *[5]- I don't know exactly what is a 'bypasser'... But I want to inject code! :-) [e]- Exit/Quit. """) ans4 = raw_input("Your choice: [1], [2], [3], [4], [5] or [e]xit\n") if ans4 == "1": # no encode enc = "Not using encoders" ans4 = None elif ans4 == "2": # enc: Hex enc = 'Hex' ans4 = None elif ans4 == "3": # enc: Str+Une enc = 'Str+Une' ans4 = None elif ans4 == "4": # enc: Mix: Une+Str+Hex enc = "Une,Str,Hex" ans4 = None elif ans4 == "5": # enc: no encode enc = 'Not using encoders' ans4 = None elif (ans4 == "e" or ans4 == "E"): print "Closing wizard..." ans4=None ans5=None ans6=None else: print "\nNot valid choice. Try again!" #step 5: Exploiting while ans5: print 22*"-" print("""\nE)- Which final code do you want to 'exploit' on vulnerabilities found?\n [1]- I want to inject a classic "Alert" message box. [2]- I want to inject my own scripts. *[3]- I don't want to inject a final code... I just want to discover vulnerabilities! :-) [e]- Exit/Quit. """) ans5 = raw_input("Your choice: [1], [2], [3] or [e]xit\n") if ans5 == "1": # alertbox script = 'Alertbox' ans5 = None elif ans5 == "2": # manual script = raw_input("Enter code (ex: '><script>alert('XSS');</script>): ") if script == None: print "\n[Error] Your are providing an empty script to inject. Try again!" pass else: ans5 = None elif ans5 == "3": # no exploit script = 'Not exploiting code' ans5 = None elif (ans5 == "e" or ans5 == "E"): print "Closing wizard..." ans5=None ans6=None else: print "\nNot valid choice. Try again!" #step 6: Final while ans6: print 22*"-" print "\nVery nice!. That's all. Your last step is to -accept or not- this template.\n" print "A)- Target:", url print "B)- Payload:", payload print "C)- Privacy:", proxy print "D)- Bypasser(s):", enc print "E)- Final:", script print(""" [Y]- Yes. Accept it and start testing!. [N]- No. Abort it?. """) ans6 = raw_input("Your choice: [Y] or [N]\n") if (ans6 == "y" or ans6 == "Y"): # YES start = 'YES' print 'Good fly... and happy "Cross" hacking !!! :-)\n' ans6 = None elif (ans6 == "n" or ans6 == "N"): # NO start = 'NO' print "Aborted!. Closing wizard..." ans6 = None else: print "\nNot valid choice. Try again!" if url and payload and proxy and enc and script: return url, payload, proxy, enc, script else: return
[ "def", "start_wizard", "(", "self", ")", ":", "#step 0: Menu", "ans1", "=", "True", "ans2", "=", "True", "ans3", "=", "True", "ans4", "=", "True", "ans5", "=", "True", "ans6", "=", "True", "#step 1: Where", "while", "ans1", ":", "print", "(", "\"\"\"\\nA...
https://github.com/pikpikcu/Pentest-Tools-Framework/blob/cd6e6107764a809943dc4e073cde8149c1a2cd03/modules/xsser/build/bdist.linux-armv7l/egg/core/main.py#L1612-L1829
ctxis/canape
5f0e03424577296bcc60c2008a60a98ec5307e4b
CANAPE.Scripting/Lib/pickle.py
python
Pickler.clear_memo
(self)
Clears the pickler's "memo". The memo is the data structure that remembers which objects the pickler has already seen, so that shared or recursive objects are pickled by reference and not by value. This method is useful when re-using picklers.
Clears the pickler's "memo".
[ "Clears", "the", "pickler", "s", "memo", "." ]
def clear_memo(self): """Clears the pickler's "memo". The memo is the data structure that remembers which objects the pickler has already seen, so that shared or recursive objects are pickled by reference and not by value. This method is useful when re-using picklers. """ self.memo.clear()
[ "def", "clear_memo", "(", "self", ")", ":", "self", ".", "memo", ".", "clear", "(", ")" ]
https://github.com/ctxis/canape/blob/5f0e03424577296bcc60c2008a60a98ec5307e4b/CANAPE.Scripting/Lib/pickle.py#L209-L218
TengXiaoDai/DistributedCrawling
f5c2439e6ce68dd9b49bde084d76473ff9ed4963
Lib/tempfile.py
python
_get_candidate_names
()
return _name_sequence
Common setup sequence for all user-callable interfaces.
Common setup sequence for all user-callable interfaces.
[ "Common", "setup", "sequence", "for", "all", "user", "-", "callable", "interfaces", "." ]
def _get_candidate_names(): """Common setup sequence for all user-callable interfaces.""" global _name_sequence if _name_sequence is None: _once_lock.acquire() try: if _name_sequence is None: _name_sequence = _RandomNameSequence() finally: _once_lock.release() return _name_sequence
[ "def", "_get_candidate_names", "(", ")", ":", "global", "_name_sequence", "if", "_name_sequence", "is", "None", ":", "_once_lock", ".", "acquire", "(", ")", "try", ":", "if", "_name_sequence", "is", "None", ":", "_name_sequence", "=", "_RandomNameSequence", "(",...
https://github.com/TengXiaoDai/DistributedCrawling/blob/f5c2439e6ce68dd9b49bde084d76473ff9ed4963/Lib/tempfile.py#L235-L246
xtiankisutsa/MARA_Framework
ac4ac88bfd38f33ae8780a606ed09ab97177c562
tools/androwarn/androwarn/search/malicious_behaviours/code_execution.py
python
gather_code_execution
(x)
return result
@param x : a VMAnalysis instance @rtype : a list strings for the concerned category, for exemple [ 'This application makes phone calls', "This application sends an SMS message 'Premium SMS' to the '12345' phone number" ]
[]
def gather_code_execution(x) : """ @param x : a VMAnalysis instance @rtype : a list strings for the concerned category, for exemple [ 'This application makes phone calls', "This application sends an SMS message 'Premium SMS' to the '12345' phone number" ] """ result = [] result.extend( detect_Library_loading(x) ) result.extend( detect_UNIX_command_execution(x) ) return result
[ "def", "gather_code_execution", "(", "x", ")", ":", "result", "=", "[", "]", "result", ".", "extend", "(", "detect_Library_loading", "(", "x", ")", ")", "result", ".", "extend", "(", "detect_UNIX_command_execution", "(", "x", ")", ")", "return", "result" ]
https://github.com/xtiankisutsa/MARA_Framework/blob/ac4ac88bfd38f33ae8780a606ed09ab97177c562/tools/androwarn/androwarn/search/malicious_behaviours/code_execution.py#L88-L99
JimmXinu/FanFicFare
bc149a2deb2636320fe50a3e374af6eef8f61889
fanficfare/adapters/adapter_pretendercentrecom.py
python
PretenderCenterComAdapter.getSiteURLPattern
(self)
return r"https?://(www\.)?"+re.escape(self.getSiteDomain()+"/missingpieces/viewstory.php?sid=")+r"\d+$"
[]
def getSiteURLPattern(self): return r"https?://(www\.)?"+re.escape(self.getSiteDomain()+"/missingpieces/viewstory.php?sid=")+r"\d+$"
[ "def", "getSiteURLPattern", "(", "self", ")", ":", "return", "r\"https?://(www\\.)?\"", "+", "re", ".", "escape", "(", "self", ".", "getSiteDomain", "(", ")", "+", "\"/missingpieces/viewstory.php?sid=\"", ")", "+", "r\"\\d+$\"" ]
https://github.com/JimmXinu/FanFicFare/blob/bc149a2deb2636320fe50a3e374af6eef8f61889/fanficfare/adapters/adapter_pretendercentrecom.py#L68-L69
twilio/twilio-python
6e1e811ea57a1edfadd5161ace87397c563f6915
twilio/twiml/voice_response.py
python
Prompt.say
(self, message=None, voice=None, loop=None, language=None, **kwargs)
return self.nest(Say(message=message, voice=voice, loop=loop, language=language, **kwargs))
Create a <Say> element :param message: Message to say :param voice: Voice to use :param loop: Times to loop message :param language: Message langauge :param kwargs: additional attributes :returns: <Say> element
Create a <Say> element
[ "Create", "a", "<Say", ">", "element" ]
def say(self, message=None, voice=None, loop=None, language=None, **kwargs): """ Create a <Say> element :param message: Message to say :param voice: Voice to use :param loop: Times to loop message :param language: Message langauge :param kwargs: additional attributes :returns: <Say> element """ return self.nest(Say(message=message, voice=voice, loop=loop, language=language, **kwargs))
[ "def", "say", "(", "self", ",", "message", "=", "None", ",", "voice", "=", "None", ",", "loop", "=", "None", ",", "language", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "nest", "(", "Say", "(", "message", "=", "message...
https://github.com/twilio/twilio-python/blob/6e1e811ea57a1edfadd5161ace87397c563f6915/twilio/twiml/voice_response.py#L644-L656
SeanLee97/xmnlp
0ffad8616c248845b18f819c0ac0465a4ec45f5d
xmnlp/radical/radical.py
python
Radical.__init__
(self)
[]
def __init__(self): self.dictionary = {}
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "dictionary", "=", "{", "}" ]
https://github.com/SeanLee97/xmnlp/blob/0ffad8616c248845b18f819c0ac0465a4ec45f5d/xmnlp/radical/radical.py#L15-L16
makerbot/ReplicatorG
d6f2b07785a5a5f1e172fb87cb4303b17c575d5d
skein_engines/skeinforge-47/fabmetheus_utilities/geometry/geometry_utilities/matrix.py
python
Matrix.addXML
(self, depth, output)
Add xml for this object.
Add xml for this object.
[ "Add", "xml", "for", "this", "object", "." ]
def addXML(self, depth, output): 'Add xml for this object.' attributes = self.getAttributes() if len(attributes) > 0: xml_simple_writer.addClosedXMLTag(attributes, depth, self.__class__.__name__.lower(), output)
[ "def", "addXML", "(", "self", ",", "depth", ",", "output", ")", ":", "attributes", "=", "self", ".", "getAttributes", "(", ")", "if", "len", "(", "attributes", ")", ">", "0", ":", "xml_simple_writer", ".", "addClosedXMLTag", "(", "attributes", ",", "dept...
https://github.com/makerbot/ReplicatorG/blob/d6f2b07785a5a5f1e172fb87cb4303b17c575d5d/skein_engines/skeinforge-47/fabmetheus_utilities/geometry/geometry_utilities/matrix.py#L457-L461
tlsfuzzer/tlslite-ng
8720db53067ba4f7bb7b5a32d682033d8b5446f9
tlslite/messages.py
python
RecordHeader2.parse
(self, parser)
return self
Deserialise object from Parser.
Deserialise object from Parser.
[ "Deserialise", "object", "from", "Parser", "." ]
def parse(self, parser): """Deserialise object from Parser.""" firstByte = parser.get(1) secondByte = parser.get(1) if firstByte & 0x80: self.length = ((firstByte & 0x7f) << 8) | secondByte else: self.length = ((firstByte & 0x3f) << 8) | secondByte self.securityEscape = firstByte & 0x40 != 0 self.padding = parser.get(1) self.type = ContentType.handshake self.version = (2, 0) return self
[ "def", "parse", "(", "self", ",", "parser", ")", ":", "firstByte", "=", "parser", ".", "get", "(", "1", ")", "secondByte", "=", "parser", ".", "get", "(", "1", ")", "if", "firstByte", "&", "0x80", ":", "self", ".", "length", "=", "(", "(", "first...
https://github.com/tlsfuzzer/tlslite-ng/blob/8720db53067ba4f7bb7b5a32d682033d8b5446f9/tlslite/messages.py#L105-L118
weechat/scripts
99ec0e7eceefabb9efb0f11ec26d45d6e8e84335
python/otr.py
python
TableFormatter.format
(self)
return '\n'.join([self.format_row(row) for row in self.rows])
Return the formatted table as a string.
Return the formatted table as a string.
[ "Return", "the", "formatted", "table", "as", "a", "string", "." ]
def format(self): """Return the formatted table as a string.""" return '\n'.join([self.format_row(row) for row in self.rows])
[ "def", "format", "(", "self", ")", ":", "return", "'\\n'", ".", "join", "(", "[", "self", ".", "format_row", "(", "row", ")", "for", "row", "in", "self", ".", "rows", "]", ")" ]
https://github.com/weechat/scripts/blob/99ec0e7eceefabb9efb0f11ec26d45d6e8e84335/python/otr.py#L1169-L1171
rwth-i6/returnn
f2d718a197a280b0d5f0fd91a7fcb8658560dddb
returnn/util/better_exchook.py
python
Color.__init__
(self, enable=None)
:param bool|None enable:
:param bool|None enable:
[ ":", "param", "bool|None", "enable", ":" ]
def __init__(self, enable=None): """ :param bool|None enable: """ if enable is None: enable = self.get_global_color_enabled() self.enable = enable self._dark_terminal_background = self.is_dark_terminal_background() # Set color palettes (will be used sometimes as bold, sometimes as normal). # 5 colors, for: code/general, error-msg, string, comment, line-nr. # Try to set them in a way such that if we guessed the terminal background color wrongly, # it is still not too bad (although people might disagree here...). if self._dark_terminal_background: self.fg_colors = ["yellow", "red", "cyan", "white", "magenta"] else: self.fg_colors = ["blue", "red", "cyan", "white", "magenta"]
[ "def", "__init__", "(", "self", ",", "enable", "=", "None", ")", ":", "if", "enable", "is", "None", ":", "enable", "=", "self", ".", "get_global_color_enabled", "(", ")", "self", ".", "enable", "=", "enable", "self", ".", "_dark_terminal_background", "=", ...
https://github.com/rwth-i6/returnn/blob/f2d718a197a280b0d5f0fd91a7fcb8658560dddb/returnn/util/better_exchook.py#L623-L638
krintoxi/NoobSec-Toolkit
38738541cbc03cedb9a3b3ed13b629f781ad64f6
NoobSecToolkit /tools/sqli/thirdparty/odict/odict.py
python
Items.__len__
(self)
return len(self._main._sequence)
[]
def __len__(self): return len(self._main._sequence) # easier :-)
[ "def", "__len__", "(", "self", ")", ":", "return", "len", "(", "self", ".", "_main", ".", "_sequence", ")", "# easier :-)" ]
https://github.com/krintoxi/NoobSec-Toolkit/blob/38738541cbc03cedb9a3b3ed13b629f781ad64f6/NoobSecToolkit /tools/sqli/thirdparty/odict/odict.py#L1032-L1032
zvtvz/zvt
054bf8a3e7a049df7087c324fa87e8effbaf5bdc
src/zvt/contract/context.py
python
Registry.__init__
(self)
[]
def __init__(self) -> None: # all registered providers self.providers = [] # all registered entity types(str) self.tradable_entity_types = [] # all entity schemas self.entity_schemas = [] # all registered schemas self.schemas = [] # tradable entity type -> schema self.tradable_schema_map = {} # global sessions self.sessions = {} # provider_dbname -> engine self.db_engine_map = {} # provider_dbname -> session self.db_session_map = {} # provider -> [db_name1,db_name2...] self.provider_map_dbnames = {} # db_name -> [declarative_base1,declarative_base2...] self.dbname_map_base = {} # db_name -> [declarative_meta1,declarative_meta2...] self.dbname_map_schemas = {} # entity_type -> related schemas self.entity_map_schemas = {} # factor class registry self.factor_cls_registry = {}
[ "def", "__init__", "(", "self", ")", "->", "None", ":", "# all registered providers", "self", ".", "providers", "=", "[", "]", "# all registered entity types(str)", "self", ".", "tradable_entity_types", "=", "[", "]", "# all entity schemas", "self", ".", "entity_sch...
https://github.com/zvtvz/zvt/blob/054bf8a3e7a049df7087c324fa87e8effbaf5bdc/src/zvt/contract/context.py#L5-L43
wistbean/learn_python3_spider
73c873f4845f4385f097e5057407d03dd37a117b
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/reflect.py
python
_importAndCheckStack
(importName)
Import the given name as a module, then walk the stack to determine whether the failure was the module not existing, or some code in the module (for example a dependent import) failing. This can be helpful to determine whether any actual application code was run. For example, to distiguish administrative error (entering the wrong module name), from programmer error (writing buggy code in a module that fails to import). @param importName: The name of the module to import. @type importName: C{str} @raise Exception: if something bad happens. This can be any type of exception, since nobody knows what loading some arbitrary code might do. @raise _NoModuleFound: if no module was found.
Import the given name as a module, then walk the stack to determine whether the failure was the module not existing, or some code in the module (for example a dependent import) failing. This can be helpful to determine whether any actual application code was run. For example, to distiguish administrative error (entering the wrong module name), from programmer error (writing buggy code in a module that fails to import).
[ "Import", "the", "given", "name", "as", "a", "module", "then", "walk", "the", "stack", "to", "determine", "whether", "the", "failure", "was", "the", "module", "not", "existing", "or", "some", "code", "in", "the", "module", "(", "for", "example", "a", "de...
def _importAndCheckStack(importName): """ Import the given name as a module, then walk the stack to determine whether the failure was the module not existing, or some code in the module (for example a dependent import) failing. This can be helpful to determine whether any actual application code was run. For example, to distiguish administrative error (entering the wrong module name), from programmer error (writing buggy code in a module that fails to import). @param importName: The name of the module to import. @type importName: C{str} @raise Exception: if something bad happens. This can be any type of exception, since nobody knows what loading some arbitrary code might do. @raise _NoModuleFound: if no module was found. """ try: return __import__(importName) except ImportError: excType, excValue, excTraceback = sys.exc_info() while excTraceback: execName = excTraceback.tb_frame.f_globals["__name__"] # in Python 2 execName is None when an ImportError is encountered, # where in Python 3 execName is equal to the importName. if execName is None or execName == importName: reraise(excValue, excTraceback) excTraceback = excTraceback.tb_next raise _NoModuleFound()
[ "def", "_importAndCheckStack", "(", "importName", ")", ":", "try", ":", "return", "__import__", "(", "importName", ")", "except", "ImportError", ":", "excType", ",", "excValue", ",", "excTraceback", "=", "sys", ".", "exc_info", "(", ")", "while", "excTraceback...
https://github.com/wistbean/learn_python3_spider/blob/73c873f4845f4385f097e5057407d03dd37a117b/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/reflect.py#L230-L257
colour-science/colour
38782ac059e8ddd91939f3432bf06811c16667f0
colour/utilities/data_structures.py
python
Node.children
(self, value)
Setter for the **self.children** property.
Setter for the **self.children** property.
[ "Setter", "for", "the", "**", "self", ".", "children", "**", "property", "." ]
def children(self, value): """ Setter for the **self.children** property. """ if value is not None: attest( isinstance(value, Sequence) and not isinstance(value, str), '"{0}" attribute: "{1}" type is not a "Sequence" instance!' .format('children', value)) for element in value: attest( issubclass(element.__class__, Node), '"{0}" attribute: A "{1}" element is not a "{2}" subclass!' .format('children', element, Node.__class__.__name__)) for node in value: node.parent = self self._children = list(value)
[ "def", "children", "(", "self", ",", "value", ")", ":", "if", "value", "is", "not", "None", ":", "attest", "(", "isinstance", "(", "value", ",", "Sequence", ")", "and", "not", "isinstance", "(", "value", ",", "str", ")", ",", "'\"{0}\" attribute: \"{1}\"...
https://github.com/colour-science/colour/blob/38782ac059e8ddd91939f3432bf06811c16667f0/colour/utilities/data_structures.py#L676-L696
etetoolkit/ete
2b207357dc2a40ccad7bfd8f54964472c72e4726
examples/treeview/node_background.py
python
layout
(node)
[]
def layout(node): if node.is_leaf(): N = AttrFace("name", fsize=30) faces.add_face_to_node(N, node, 0, position="aligned")
[ "def", "layout", "(", "node", ")", ":", "if", "node", ".", "is_leaf", "(", ")", ":", "N", "=", "AttrFace", "(", "\"name\"", ",", "fsize", "=", "30", ")", "faces", ".", "add_face_to_node", "(", "N", ",", "node", ",", "0", ",", "position", "=", "\"...
https://github.com/etetoolkit/ete/blob/2b207357dc2a40ccad7bfd8f54964472c72e4726/examples/treeview/node_background.py#L3-L6
jupyterlab/jupyterlab-latex
e6deb0bba7785d5fcc1d88dd907e44e92c1af895
setupbase.py
python
_iexplode_path
(path)
Iterate over all the parts of a path. Splits path recursively with os.path.split().
Iterate over all the parts of a path.
[ "Iterate", "over", "all", "the", "parts", "of", "a", "path", "." ]
def _iexplode_path(path): """Iterate over all the parts of a path. Splits path recursively with os.path.split(). """ (head, tail) = os.path.split(path) if not head or (not tail and head == path): if head: yield head if tail or not head: yield tail return for p in _iexplode_path(head): yield p yield tail
[ "def", "_iexplode_path", "(", "path", ")", ":", "(", "head", ",", "tail", ")", "=", "os", ".", "path", ".", "split", "(", "path", ")", "if", "not", "head", "or", "(", "not", "tail", "and", "head", "==", "path", ")", ":", "if", "head", ":", "yie...
https://github.com/jupyterlab/jupyterlab-latex/blob/e6deb0bba7785d5fcc1d88dd907e44e92c1af895/setupbase.py#L616-L630
angr/angr
4b04d56ace135018083d36d9083805be8146688b
angr/analyses/calling_convention.py
python
CallingConventionAnalysis._reorder_args
(self, args, cc)
return reg_args + args + stack_args
Reorder arguments according to the calling convention identified. :param set args: A list of arguments that haven't been ordered. :param SimCC cc: The identified calling convention. :return: A reordered list of args.
Reorder arguments according to the calling convention identified.
[ "Reorder", "arguments", "according", "to", "the", "calling", "convention", "identified", "." ]
def _reorder_args(self, args, cc): """ Reorder arguments according to the calling convention identified. :param set args: A list of arguments that haven't been ordered. :param SimCC cc: The identified calling convention. :return: A reordered list of args. """ reg_args = [ ] for reg_name in cc.ARG_REGS: try: arg = next(iter(a for a in args if isinstance(a, SimRegArg) and a.reg_name == reg_name)) except StopIteration: # have we reached the end of the args list? if [ a for a in args if isinstance(a, SimRegArg) ]: # nope arg = SimRegArg(reg_name, self.project.arch.bytes) else: break reg_args.append(arg) if arg in args: args.remove(arg) stack_args = sorted([a for a in args if isinstance(a, SimStackArg)], key=lambda a: a.stack_offset) args = [ a for a in args if not isinstance(a, SimStackArg) ] return reg_args + args + stack_args
[ "def", "_reorder_args", "(", "self", ",", "args", ",", "cc", ")", ":", "reg_args", "=", "[", "]", "for", "reg_name", "in", "cc", ".", "ARG_REGS", ":", "try", ":", "arg", "=", "next", "(", "iter", "(", "a", "for", "a", "in", "args", "if", "isinsta...
https://github.com/angr/angr/blob/4b04d56ace135018083d36d9083805be8146688b/angr/analyses/calling_convention.py#L497-L525
vietnlp/etnlp
c82f1dd451a66cdfb3cd8e02a047ecec31df1636
src/codes/utils/embedding_io.py
python
load_words_raw
(file_path: str, emb_config: EmbeddingConfigs)
return words
Load the file as-is, without doing any validation or cleanup. :param file_path: :param emb_config: :return:
Load the file as-is, without doing any validation or cleanup. :param file_path: :param emb_config: :return:
[ "Load", "the", "file", "as", "-", "is", "without", "doing", "any", "validation", "or", "cleanup", ".", ":", "param", "file_path", ":", ":", "param", "emb_config", ":", ":", "return", ":" ]
def load_words_raw(file_path: str, emb_config: EmbeddingConfigs) -> List[Word]: """ Load the file as-is, without doing any validation or cleanup. :param file_path: :param emb_config: :return: """ def parse_line(line: str, frequency: int) -> Word: # print("Line=", line) tokens = line.split(" ") word = tokens[0] if emb_config.do_normalize_emb: vector = v.normalize(np.array([float(x) for x in tokens[1:]])) else: vector = np.array([float(x) for x in tokens[1:]]) return Word(word, vector, frequency) # Sonvx: NOT loading the same word twice. unique_dict = {} words = [] # Words are sorted from the most common to the least common ones frequency = 1 duplicated_entry = 0 idx_counter, vocab_size, emb_dim = 0, 0, 0 with open(file_path) as f: for line in f: line = line.rstrip() # print("Processing line: ", line) if idx_counter == 0 and emb_config.is_word2vec_format: try: meta_info = line.split(" ") vocab_size = int(meta_info[0]) emb_dim = int(meta_info[1]) idx_counter += 1 continue except Exception as e: print("meta_info = "%(meta_info)) logging.error("Input embedding has format issue: Error = %s" % (e)) # if len(line) < 20: # Ignore the first line of w2v format. # continue w = parse_line(line, frequency) # Svx: only load if the word is not existed in the list. if w.text not in unique_dict: unique_dict[w.text] = frequency words.append(w) frequency += 1 else: duplicated_entry += 1 # print("Loading the same word again") # # Svx: check if the embedding dim is the same with the metadata, random check only if idx_counter == 10: if len(w.vector) != emb_dim: message = "Metadata and the real vector size do not match: meta:real = %s:%s" \ % (emb_dim, len(w.vector)) logging.error(message) raise ValueError(message) idx_counter += 1 if duplicated_entry > 0: logging.debug("Loading the same word again: %s"%(duplicated_entry)) # Final check: if (frequency - 1) != vocab_size: msg = "Loaded %s/%s unique vocab." % ((frequency - 1), vocab_size) logging.info(msg) return words
[ "def", "load_words_raw", "(", "file_path", ":", "str", ",", "emb_config", ":", "EmbeddingConfigs", ")", "->", "List", "[", "Word", "]", ":", "def", "parse_line", "(", "line", ":", "str", ",", "frequency", ":", "int", ")", "->", "Word", ":", "# print(\"Li...
https://github.com/vietnlp/etnlp/blob/c82f1dd451a66cdfb3cd8e02a047ecec31df1636/src/codes/utils/embedding_io.py#L88-L165
flairNLP/flair
b774774752c8338aab3d620f7e5062f66ec7a69d
flair/datasets/biomedical.py
python
bioc_to_internal
(bioc_file: Path)
return InternalBioNerDataset(documents=texts_per_document, entities_per_document=entities_per_document)
Helper function to parse corpora that are given in BIOC format. See http://bioc.sourceforge.net/ for details.
Helper function to parse corpora that are given in BIOC format. See
[ "Helper", "function", "to", "parse", "corpora", "that", "are", "given", "in", "BIOC", "format", ".", "See" ]
def bioc_to_internal(bioc_file: Path): """ Helper function to parse corpora that are given in BIOC format. See http://bioc.sourceforge.net/ for details. """ tree = etree.parse(str(bioc_file)) texts_per_document = {} entities_per_document = {} documents = tree.xpath(".//document") all_entities = 0 non_matching = 0 for document in Tqdm.tqdm(documents, desc="Converting to internal"): document_id = document.xpath("./id")[0].text texts: List[str] = [] entities = [] for passage in document.xpath("passage"): passage_texts = passage.xpath("text/text()") if len(passage_texts) == 0: continue text = passage_texts[0] passage_offset = int(passage.xpath("./offset/text()")[0]) # from BioC annotation # calculate offset without current text # because we stick all passages of a document together document_text = " ".join(texts) document_offset = len(document_text) texts.append(text) document_text += " " + text for annotation in passage.xpath(".//annotation"): entity_types = [ i.text.replace(" ", "_") for i in annotation.xpath("./infon") if i.attrib["key"] in {"type", "class"} ] start = int(annotation.xpath("./location")[0].get("offset")) - passage_offset # TODO For split entities we also annotate everything inbetween which might be a bad idea? final_length = int(annotation.xpath("./location")[-1].get("length")) final_offset = int(annotation.xpath("./location")[-1].get("offset")) - passage_offset if final_length <= 0: continue end = final_offset + final_length start += document_offset end += document_offset true_entity = annotation.xpath(".//text")[0].text annotated_entity = " ".join(texts)[start:end] # Try to fix incorrect annotations if annotated_entity.lower() != true_entity.lower(): max_shift = min(3, len(true_entity)) for i in range(max_shift): index = annotated_entity.lower().find(true_entity[0 : max_shift - i].lower()) if index != -1: start += index end += index break annotated_entity = " ".join(texts)[start:end] if not annotated_entity.lower() == true_entity.lower(): non_matching += 1 all_entities += 1 for entity_type in entity_types: entities.append(Entity((start, end), entity_type)) texts_per_document[document_id] = " ".join(texts) entities_per_document[document_id] = entities # print( # f"Found {non_matching} non-matching entities ({non_matching/all_entities}%) in {bioc_file}" # ) return InternalBioNerDataset(documents=texts_per_document, entities_per_document=entities_per_document)
[ "def", "bioc_to_internal", "(", "bioc_file", ":", "Path", ")", ":", "tree", "=", "etree", ".", "parse", "(", "str", "(", "bioc_file", ")", ")", "texts_per_document", "=", "{", "}", "entities_per_document", "=", "{", "}", "documents", "=", "tree", ".", "x...
https://github.com/flairNLP/flair/blob/b774774752c8338aab3d620f7e5062f66ec7a69d/flair/datasets/biomedical.py#L186-L271
kovidgoyal/calibre
2b41671370f2a9eb1109b9ae901ccf915f1bd0c8
src/calibre/ebooks/pdb/ereader/reader202.py
python
Reader202.dump_images
(self, output_dir)
This is primarily used for debugging and 3rd party tools to get the images in the file.
This is primarily used for debugging and 3rd party tools to get the images in the file.
[ "This", "is", "primarily", "used", "for", "debugging", "and", "3rd", "party", "tools", "to", "get", "the", "images", "in", "the", "file", "." ]
def dump_images(self, output_dir): ''' This is primarily used for debugging and 3rd party tools to get the images in the file. ''' if not os.path.exists(output_dir): os.makedirs(output_dir) with CurrentDir(output_dir): for i in range(0, self.header_record.num_image_pages): name, img = self.get_image(self.header_record.image_data_offset + i) with open(name, 'wb') as imgf: imgf.write(img)
[ "def", "dump_images", "(", "self", ",", "output_dir", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "output_dir", ")", ":", "os", ".", "makedirs", "(", "output_dir", ")", "with", "CurrentDir", "(", "output_dir", ")", ":", "for", "i", ...
https://github.com/kovidgoyal/calibre/blob/2b41671370f2a9eb1109b9ae901ccf915f1bd0c8/src/calibre/ebooks/pdb/ereader/reader202.py#L154-L166
trakt/Plex-Trakt-Scrobbler
aeb0bfbe62fad4b06c164f1b95581da7f35dce0b
Trakttv.bundle/Contents/Libraries/Shared/sortedcontainers/sortedlist.py
python
SortedListWithKey.insert
(self, idx, val)
Insert the element *val* into the list at *idx*. Raises a ValueError if the *val* at *idx* would violate the sort order.
Insert the element *val* into the list at *idx*. Raises a ValueError if the *val* at *idx* would violate the sort order.
[ "Insert", "the", "element", "*", "val", "*", "into", "the", "list", "at", "*", "idx", "*", ".", "Raises", "a", "ValueError", "if", "the", "*", "val", "*", "at", "*", "idx", "*", "would", "violate", "the", "sort", "order", "." ]
def insert(self, idx, val): """ Insert the element *val* into the list at *idx*. Raises a ValueError if the *val* at *idx* would violate the sort order. """ _len = self._len _lists = self._lists _keys = self._keys _maxes = self._maxes if idx < 0: idx += _len if idx < 0: idx = 0 if idx > _len: idx = _len key = self._key(val) if not _maxes: self._len = 1 _lists.append([val]) _keys.append([key]) _maxes.append(key) return if not idx: if key > _keys[0][0]: msg = '{0} not in sort order at index {1}'.format(repr(val), 0) raise ValueError(msg) else: self._len += 1 _lists[0].insert(0, val) _keys[0].insert(0, key) self._expand(0) return if idx == _len: pos = len(_keys) - 1 if _keys[pos][-1] > key: msg = '{0} not in sort order at index {1}'.format(repr(val), _len) raise ValueError(msg) else: self._len += 1 _lists[pos].append(val) _keys[pos].append(key) _maxes[pos] = _keys[pos][-1] self._expand(pos) return pos, idx = self._pos(idx) idx_before = idx - 1 if idx_before < 0: pos_before = pos - 1 idx_before = len(_keys[pos_before]) - 1 else: pos_before = pos before = _keys[pos_before][idx_before] if before <= key <= _keys[pos][idx]: self._len += 1 _lists[pos].insert(idx, val) _keys[pos].insert(idx, key) self._expand(pos) else: msg = '{0} not in sort order at index {1}'.format(repr(val), idx) raise ValueError(msg)
[ "def", "insert", "(", "self", ",", "idx", ",", "val", ")", ":", "_len", "=", "self", ".", "_len", "_lists", "=", "self", ".", "_lists", "_keys", "=", "self", ".", "_keys", "_maxes", "=", "self", ".", "_maxes", "if", "idx", "<", "0", ":", "idx", ...
https://github.com/trakt/Plex-Trakt-Scrobbler/blob/aeb0bfbe62fad4b06c164f1b95581da7f35dce0b/Trakttv.bundle/Contents/Libraries/Shared/sortedcontainers/sortedlist.py#L2215-L2281
psychopy/psychopy
01b674094f38d0e0bd51c45a6f66f671d7041696
psychopy/visual/custommouse.py
python
CustomMouse.setPos
(self, pos)
Not implemented yet. Place the mouse at a specific position.
Not implemented yet. Place the mouse at a specific position.
[ "Not", "implemented", "yet", ".", "Place", "the", "mouse", "at", "a", "specific", "position", "." ]
def setPos(self, pos): """Not implemented yet. Place the mouse at a specific position. """ raise NotImplementedError('setPos is not available for custom mouse')
[ "def", "setPos", "(", "self", ",", "pos", ")", ":", "raise", "NotImplementedError", "(", "'setPos is not available for custom mouse'", ")" ]
https://github.com/psychopy/psychopy/blob/01b674094f38d0e0bd51c45a6f66f671d7041696/psychopy/visual/custommouse.py#L150-L153
openshift/openshift-tools
1188778e728a6e4781acf728123e5b356380fe6f
openshift/installer/vendored/openshift-ansible-3.10.0-0.29.0/roles/lib_vendored_deps/library/oc_adm_registry.py
python
Registry.prepared_registry
(self, data)
setter method for prepared_registry attribute
setter method for prepared_registry attribute
[ "setter", "method", "for", "prepared_registry", "attribute" ]
def prepared_registry(self, data): ''' setter method for prepared_registry attribute ''' self.__prepared_registry = data
[ "def", "prepared_registry", "(", "self", ",", "data", ")", ":", "self", ".", "__prepared_registry", "=", "data" ]
https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/openshift/installer/vendored/openshift-ansible-3.10.0-0.29.0/roles/lib_vendored_deps/library/oc_adm_registry.py#L2424-L2426
bruderstein/PythonScript
df9f7071ddf3a079e3a301b9b53a6dc78cf1208f
PythonLib/full/linecache.py
python
lazycache
(filename, module_globals)
return False
Seed the cache for filename with module_globals. The module loader will be asked for the source only when getlines is called, not immediately. If there is an entry in the cache already, it is not altered. :return: True if a lazy load is registered in the cache, otherwise False. To register such a load a module loader with a get_source method must be found, the filename must be a cacheable filename, and the filename must not be already cached.
Seed the cache for filename with module_globals.
[ "Seed", "the", "cache", "for", "filename", "with", "module_globals", "." ]
def lazycache(filename, module_globals): """Seed the cache for filename with module_globals. The module loader will be asked for the source only when getlines is called, not immediately. If there is an entry in the cache already, it is not altered. :return: True if a lazy load is registered in the cache, otherwise False. To register such a load a module loader with a get_source method must be found, the filename must be a cacheable filename, and the filename must not be already cached. """ if filename in cache: if len(cache[filename]) == 1: return True else: return False if not filename or (filename.startswith('<') and filename.endswith('>')): return False # Try for a __loader__, if available if module_globals and '__name__' in module_globals: name = module_globals['__name__'] if (loader := module_globals.get('__loader__')) is None: if spec := module_globals.get('__spec__'): try: loader = spec.loader except AttributeError: pass get_source = getattr(loader, 'get_source', None) if name and get_source: get_lines = functools.partial(get_source, name) cache[filename] = (get_lines,) return True return False
[ "def", "lazycache", "(", "filename", ",", "module_globals", ")", ":", "if", "filename", "in", "cache", ":", "if", "len", "(", "cache", "[", "filename", "]", ")", "==", "1", ":", "return", "True", "else", ":", "return", "False", "if", "not", "filename",...
https://github.com/bruderstein/PythonScript/blob/df9f7071ddf3a079e3a301b9b53a6dc78cf1208f/PythonLib/full/linecache.py#L147-L182
donnemartin/gitsome
d7c57abc7cb66e9c910a844f15d4536866da3310
xonsh/ply/example/optcalc/calc.py
python
p_expression_number
(t)
expression : NUMBER
expression : NUMBER
[ "expression", ":", "NUMBER" ]
def p_expression_number(t): 'expression : NUMBER' t[0] = t[1]
[ "def", "p_expression_number", "(", "t", ")", ":", "t", "[", "0", "]", "=", "t", "[", "1", "]" ]
https://github.com/donnemartin/gitsome/blob/d7c57abc7cb66e9c910a844f15d4536866da3310/xonsh/ply/example/optcalc/calc.py#L106-L108
OpenRCE/sulley
bff0dd1864d055eb4bfa8aacbbb6ecf215e4db4b
sulley/pedrpc.py
python
client.__connect
(self)
Connect to the PED-RPC server.
Connect to the PED-RPC server.
[ "Connect", "to", "the", "PED", "-", "RPC", "server", "." ]
def __connect (self): ''' Connect to the PED-RPC server. ''' # if we have a pre-existing server socket, ensure it's closed. self.__disconnect() # connect to the server, timeout on failure. try: self.__server_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.__server_sock.settimeout(3.0) self.__server_sock.connect((self.__host, self.__port)) except: if self.__retry != 5: self.__retry += 1 time.sleep(5) self.__connect() else: sys.stderr.write("PED-RPC> unable to connect to server %s:%d\n" % (self.__host, self.__port)) raise Exception # disable timeouts and lingering. self.__server_sock.settimeout(None) self.__server_sock.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, self.NOLINGER)
[ "def", "__connect", "(", "self", ")", ":", "# if we have a pre-existing server socket, ensure it's closed.", "self", ".", "__disconnect", "(", ")", "# connect to the server, timeout on failure.", "try", ":", "self", ".", "__server_sock", "=", "socket", ".", "socket", "(",...
https://github.com/OpenRCE/sulley/blob/bff0dd1864d055eb4bfa8aacbbb6ecf215e4db4b/sulley/pedrpc.py#L37-L60
djblets/djblets
0496e1ec49e43d43d776768c9fc5b6f8af56ec2c
djblets/avatars/services/base.py
python
AvatarService.is_configurable
(cls)
return cls.config_form_class is not None
Return whether or not the service is configurable. Returns: bool: Whether or not the service is configurable.
Return whether or not the service is configurable.
[ "Return", "whether", "or", "not", "the", "service", "is", "configurable", "." ]
def is_configurable(cls): """Return whether or not the service is configurable. Returns: bool: Whether or not the service is configurable. """ return cls.config_form_class is not None
[ "def", "is_configurable", "(", "cls", ")", ":", "return", "cls", ".", "config_form_class", "is", "not", "None" ]
https://github.com/djblets/djblets/blob/0496e1ec49e43d43d776768c9fc5b6f8af56ec2c/djblets/avatars/services/base.py#L68-L75
ialbert/biostar-central
2dc7bd30691a50b2da9c2833ba354056bc686afa
biostar/planet/auth.py
python
create_blogpost
(entry, blog)
return
[]
def create_blogpost(entry, blog): date = entry.get('date_parsed') or entry.get('published_parsed') date = datetime(date[0], date[1], date[2]) date = timezone.make_aware(date, timezone=timezone.utc) if not entry.title: return # body = html.clean(entry.description)[:5000] body = entry.description content = strip_tags(body) try: post = BlogPost.objects.create(title=entry.title, blog=blog, uid=entry.id, content=content, html=body, creation_date=date, link=entry.link) except Exception as exc: logger.error(entry.id) logger.warning(f"database error {exc}") else: logger.info(f"added: {post.title}") return
[ "def", "create_blogpost", "(", "entry", ",", "blog", ")", ":", "date", "=", "entry", ".", "get", "(", "'date_parsed'", ")", "or", "entry", ".", "get", "(", "'published_parsed'", ")", "date", "=", "datetime", "(", "date", "[", "0", "]", ",", "date", "...
https://github.com/ialbert/biostar-central/blob/2dc7bd30691a50b2da9c2833ba354056bc686afa/biostar/planet/auth.py#L22-L43
PokemonGoF/PokemonGo-Bot-Desktop
4bfa94f0183406c6a86f93645eff7abd3ad4ced8
build/pywin/Lib/fractions.py
python
Fraction.__trunc__
(a)
trunc(a)
trunc(a)
[ "trunc", "(", "a", ")" ]
def __trunc__(a): """trunc(a)""" if a._numerator < 0: return -(-a._numerator // a._denominator) else: return a._numerator // a._denominator
[ "def", "__trunc__", "(", "a", ")", ":", "if", "a", ".", "_numerator", "<", "0", ":", "return", "-", "(", "-", "a", ".", "_numerator", "//", "a", ".", "_denominator", ")", "else", ":", "return", "a", ".", "_numerator", "//", "a", ".", "_denominator"...
https://github.com/PokemonGoF/PokemonGo-Bot-Desktop/blob/4bfa94f0183406c6a86f93645eff7abd3ad4ced8/build/pywin/Lib/fractions.py#L501-L506
PaddlePaddle/PaddleX
2bab73f81ab54e328204e7871e6ae4a82e719f5d
paddlex/cv/models/classifier.py
python
ResNet34.__init__
(self, num_classes=1000, **params)
[]
def __init__(self, num_classes=1000, **params): super(ResNet34, self).__init__( model_name='ResNet34', num_classes=num_classes, **params)
[ "def", "__init__", "(", "self", ",", "num_classes", "=", "1000", ",", "*", "*", "params", ")", ":", "super", "(", "ResNet34", ",", "self", ")", ".", "__init__", "(", "model_name", "=", "'ResNet34'", ",", "num_classes", "=", "num_classes", ",", "*", "*"...
https://github.com/PaddlePaddle/PaddleX/blob/2bab73f81ab54e328204e7871e6ae4a82e719f5d/paddlex/cv/models/classifier.py#L536-L538
andresriancho/w3af
cd22e5252243a87aaa6d0ddea47cf58dacfe00a9
w3af/core/ui/gui/helpers.py
python
PropagateBuffer.__init__
(self, target)
[]
def __init__(self, target): self.target = target self.alerted = {} self.last_notified = None
[ "def", "__init__", "(", "self", ",", "target", ")", ":", "self", ".", "target", "=", "target", "self", ".", "alerted", "=", "{", "}", "self", ".", "last_notified", "=", "None" ]
https://github.com/andresriancho/w3af/blob/cd22e5252243a87aaa6d0ddea47cf58dacfe00a9/w3af/core/ui/gui/helpers.py#L42-L45
mchristopher/PokemonGo-DesktopMap
ec37575f2776ee7d64456e2a1f6b6b78830b4fe0
app/pywin/Lib/cookielib.py
python
CookieJar.add_cookie_header
(self, request)
Add correct Cookie: header to request (urllib2.Request object). The Cookie2 header is also added unless policy.hide_cookie2 is true.
Add correct Cookie: header to request (urllib2.Request object).
[ "Add", "correct", "Cookie", ":", "header", "to", "request", "(", "urllib2", ".", "Request", "object", ")", "." ]
def add_cookie_header(self, request): """Add correct Cookie: header to request (urllib2.Request object). The Cookie2 header is also added unless policy.hide_cookie2 is true. """ _debug("add_cookie_header") self._cookies_lock.acquire() try: self._policy._now = self._now = int(time.time()) cookies = self._cookies_for_request(request) attrs = self._cookie_attrs(cookies) if attrs: if not request.has_header("Cookie"): request.add_unredirected_header( "Cookie", "; ".join(attrs)) # if necessary, advertise that we know RFC 2965 if (self._policy.rfc2965 and not self._policy.hide_cookie2 and not request.has_header("Cookie2")): for cookie in cookies: if cookie.version != 1: request.add_unredirected_header("Cookie2", '$Version="1"') break finally: self._cookies_lock.release() self.clear_expired_cookies()
[ "def", "add_cookie_header", "(", "self", ",", "request", ")", ":", "_debug", "(", "\"add_cookie_header\"", ")", "self", ".", "_cookies_lock", ".", "acquire", "(", ")", "try", ":", "self", ".", "_policy", ".", "_now", "=", "self", ".", "_now", "=", "int",...
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/ec37575f2776ee7d64456e2a1f6b6b78830b4fe0/app/pywin/Lib/cookielib.py#L1328-L1359
oracle/graalpython
577e02da9755d916056184ec441c26e00b70145c
graalpython/lib-python/3/argparse.py
python
_ActionsContainer._handle_conflict_error
(self, action, conflicting_actions)
[]
def _handle_conflict_error(self, action, conflicting_actions): message = ngettext('conflicting option string: %s', 'conflicting option strings: %s', len(conflicting_actions)) conflict_string = ', '.join([option_string for option_string, action in conflicting_actions]) raise ArgumentError(action, message % conflict_string)
[ "def", "_handle_conflict_error", "(", "self", ",", "action", ",", "conflicting_actions", ")", ":", "message", "=", "ngettext", "(", "'conflicting option string: %s'", ",", "'conflicting option strings: %s'", ",", "len", "(", "conflicting_actions", ")", ")", "conflict_st...
https://github.com/oracle/graalpython/blob/577e02da9755d916056184ec441c26e00b70145c/graalpython/lib-python/3/argparse.py#L1541-L1548
kanzure/nanoengineer
874e4c9f8a9190f093625b267f9767e19f82e6c4
cad/src/operations/ops_copy.py
python
ops_copy_Mixin._getInitialPasteOffsetForPastableNodes
(self, original_copied_nodes)
return initial_offset_for_chunks, initial_offset_for_other_pastables
@see: self._pasteGroup(), self._pasteChunk() What it supports: 1. User selects some objects 2. Hits Ctrl + C 3. Hits Ctrl + V - first ctrl V pastes object at an offset, (doesn't recenter the view) to the original one - 2nd paste offsets it further and like that.... This fixes bug 2890
@see: self._pasteGroup(), self._pasteChunk() What it supports: 1. User selects some objects 2. Hits Ctrl + C 3. Hits Ctrl + V - first ctrl V pastes object at an offset, (doesn't recenter the view) to the original one - 2nd paste offsets it further and like that....
[ "@see", ":", "self", ".", "_pasteGroup", "()", "self", ".", "_pasteChunk", "()", "What", "it", "supports", ":", "1", ".", "User", "selects", "some", "objects", "2", ".", "Hits", "Ctrl", "+", "C", "3", ".", "Hits", "Ctrl", "+", "V", "-", "first", "c...
def _getInitialPasteOffsetForPastableNodes(self, original_copied_nodes): # by Ninad """ @see: self._pasteGroup(), self._pasteChunk() What it supports: 1. User selects some objects 2. Hits Ctrl + C 3. Hits Ctrl + V - first ctrl V pastes object at an offset, (doesn't recenter the view) to the original one - 2nd paste offsets it further and like that.... This fixes bug 2890 """ #@TODO: Review this method. It was added just before v1.1.0 to fix a #copy-paste-pasteagain-pasteagain bug -- Ninad 2008-06-06 if same_vals(original_copied_nodes, self._previously_pasted_node_list): initial_offset_for_chunks = self._initial_paste_offset_for_chunks initial_offset_for_other_pastables = self._initial_paste_offset_for_other_pastables else: initial_offset_for_chunks = V(0, 0, 0) initial_offset_for_other_pastables = V(0, 0, 0) self._previously_pasted_node_list = original_copied_nodes return initial_offset_for_chunks, initial_offset_for_other_pastables
[ "def", "_getInitialPasteOffsetForPastableNodes", "(", "self", ",", "original_copied_nodes", ")", ":", "# by Ninad", "#@TODO: Review this method. It was added just before v1.1.0 to fix a", "#copy-paste-pasteagain-pasteagain bug -- Ninad 2008-06-06", "if", "same_vals", "(", "original_copie...
https://github.com/kanzure/nanoengineer/blob/874e4c9f8a9190f093625b267f9767e19f82e6c4/cad/src/operations/ops_copy.py#L770-L795
bslatkin/effectivepython
4ae6f3141291ea137eb29a245bf889dbc8091713
example_code/item_14.py
python
Tool.__repr__
(self)
return f'Tool({self.name!r}, {self.weight})'
[]
def __repr__(self): return f'Tool({self.name!r}, {self.weight})'
[ "def", "__repr__", "(", "self", ")", ":", "return", "f'Tool({self.name!r}, {self.weight})'" ]
https://github.com/bslatkin/effectivepython/blob/4ae6f3141291ea137eb29a245bf889dbc8091713/example_code/item_14.py#L61-L62
RasaHQ/rasa
54823b68c1297849ba7ae841a4246193cd1223a1
rasa/utils/tensorflow/environment.py
python
_setup_gpu_environment
()
Sets configuration for TensorFlow GPU environment based on env variable.
Sets configuration for TensorFlow GPU environment based on env variable.
[ "Sets", "configuration", "for", "TensorFlow", "GPU", "environment", "based", "on", "env", "variable", "." ]
def _setup_gpu_environment() -> None: """Sets configuration for TensorFlow GPU environment based on env variable.""" gpu_memory_config = os.getenv(ENV_GPU_CONFIG) if not gpu_memory_config: return # Import from tensorflow only if necessary (environment variable was set) from tensorflow import config as tf_config parsed_gpu_config = _parse_gpu_config(gpu_memory_config) physical_gpus = tf_config.list_physical_devices("GPU") # Logic taken from https://www.tensorflow.org/guide/gpu if physical_gpus: for gpu_id, gpu_id_memory in parsed_gpu_config.items(): _allocate_gpu_memory(physical_gpus[gpu_id], gpu_id_memory) else: rasa.shared.utils.io.raise_warning( f"You have an environment variable '{ENV_GPU_CONFIG}' set but no GPUs were " f"detected to configure." )
[ "def", "_setup_gpu_environment", "(", ")", "->", "None", ":", "gpu_memory_config", "=", "os", ".", "getenv", "(", "ENV_GPU_CONFIG", ")", "if", "not", "gpu_memory_config", ":", "return", "# Import from tensorflow only if necessary (environment variable was set)", "from", "...
https://github.com/RasaHQ/rasa/blob/54823b68c1297849ba7ae841a4246193cd1223a1/rasa/utils/tensorflow/environment.py#L21-L43
khanhnamle1994/natural-language-processing
01d450d5ac002b0156ef4cf93a07cb508c1bcdc5
assignment1/.env/lib/python2.7/site-packages/numpy/ma/core.py
python
minimum_fill_value
(obj)
Return the maximum value that can be represented by the dtype of an object. This function is useful for calculating a fill value suitable for taking the minimum of an array with a given dtype. Parameters ---------- obj : ndarray or dtype An object that can be queried for it's numeric type. Returns ------- val : scalar The maximum representable value. Raises ------ TypeError If `obj` isn't a suitable numeric type. See Also -------- maximum_fill_value : The inverse function. set_fill_value : Set the filling value of a masked array. MaskedArray.fill_value : Return current fill value. Examples -------- >>> import numpy.ma as ma >>> a = np.int8() >>> ma.minimum_fill_value(a) 127 >>> a = np.int32() >>> ma.minimum_fill_value(a) 2147483647 An array of numeric data can also be passed. >>> a = np.array([1, 2, 3], dtype=np.int8) >>> ma.minimum_fill_value(a) 127 >>> a = np.array([1, 2, 3], dtype=np.float32) >>> ma.minimum_fill_value(a) inf
Return the maximum value that can be represented by the dtype of an object.
[ "Return", "the", "maximum", "value", "that", "can", "be", "represented", "by", "the", "dtype", "of", "an", "object", "." ]
def minimum_fill_value(obj): """ Return the maximum value that can be represented by the dtype of an object. This function is useful for calculating a fill value suitable for taking the minimum of an array with a given dtype. Parameters ---------- obj : ndarray or dtype An object that can be queried for it's numeric type. Returns ------- val : scalar The maximum representable value. Raises ------ TypeError If `obj` isn't a suitable numeric type. See Also -------- maximum_fill_value : The inverse function. set_fill_value : Set the filling value of a masked array. MaskedArray.fill_value : Return current fill value. Examples -------- >>> import numpy.ma as ma >>> a = np.int8() >>> ma.minimum_fill_value(a) 127 >>> a = np.int32() >>> ma.minimum_fill_value(a) 2147483647 An array of numeric data can also be passed. >>> a = np.array([1, 2, 3], dtype=np.int8) >>> ma.minimum_fill_value(a) 127 >>> a = np.array([1, 2, 3], dtype=np.float32) >>> ma.minimum_fill_value(a) inf """ errmsg = "Unsuitable type for calculating minimum." if hasattr(obj, 'dtype'): return _recursive_extremum_fill_value(obj.dtype, min_filler) elif isinstance(obj, float): return min_filler[ntypes.typeDict['float_']] elif isinstance(obj, int): return min_filler[ntypes.typeDict['int_']] elif isinstance(obj, long): return min_filler[ntypes.typeDict['uint']] elif isinstance(obj, np.dtype): return min_filler[obj] else: raise TypeError(errmsg)
[ "def", "minimum_fill_value", "(", "obj", ")", ":", "errmsg", "=", "\"Unsuitable type for calculating minimum.\"", "if", "hasattr", "(", "obj", ",", "'dtype'", ")", ":", "return", "_recursive_extremum_fill_value", "(", "obj", ".", "dtype", ",", "min_filler", ")", "...
https://github.com/khanhnamle1994/natural-language-processing/blob/01d450d5ac002b0156ef4cf93a07cb508c1bcdc5/assignment1/.env/lib/python2.7/site-packages/numpy/ma/core.py#L236-L296
Source-Python-Dev-Team/Source.Python
d0ffd8ccbd1e9923c9bc44936f20613c1c76b7fb
addons/source-python/packages/site-packages/docutils/utils/math/math2html.py
python
HeaderParser.complete
(self, ending)
return self
Complete the parser with the given ending.
Complete the parser with the given ending.
[ "Complete", "the", "parser", "with", "the", "given", "ending", "." ]
def complete(self, ending): "Complete the parser with the given ending." self.ending = ending return self
[ "def", "complete", "(", "self", ",", "ending", ")", ":", "self", ".", "ending", "=", "ending", "return", "self" ]
https://github.com/Source-Python-Dev-Team/Source.Python/blob/d0ffd8ccbd1e9923c9bc44936f20613c1c76b7fb/addons/source-python/packages/site-packages/docutils/utils/math/math2html.py#L4992-L4995
ahmetozlu/vehicle_counting_tensorflow
ce4e86107f36404cdb91c38bf8514983df5e5153
utils/label_map_util.py
python
convert_label_map_to_categories
(label_map, max_num_classes, use_display_name=True)
return categories
Loads label map proto and returns categories list compatible with eval. This function loads a label map and returns a list of dicts, each of which has the following keys: 'id': (required) an integer id uniquely identifying this category. 'name': (required) string representing category name e.g., 'cat', 'dog', 'pizza'. We only allow class into the list if its id-label_id_offset is between 0 (inclusive) and max_num_classes (exclusive). If there are several items mapping to the same id in the label map, we will only keep the first one in the categories list. Args: label_map: a StringIntLabelMapProto or None. If None, a default categories list is created with max_num_classes categories. max_num_classes: maximum number of (consecutive) label indices to include. use_display_name: (boolean) choose whether to load 'display_name' field as category name. If False or if the display_name field does not exist, uses 'name' field as category names instead. Returns: categories: a list of dictionaries representing all possible categories.
Loads label map proto and returns categories list compatible with eval.
[ "Loads", "label", "map", "proto", "and", "returns", "categories", "list", "compatible", "with", "eval", "." ]
def convert_label_map_to_categories(label_map, max_num_classes, use_display_name=True): """Loads label map proto and returns categories list compatible with eval. This function loads a label map and returns a list of dicts, each of which has the following keys: 'id': (required) an integer id uniquely identifying this category. 'name': (required) string representing category name e.g., 'cat', 'dog', 'pizza'. We only allow class into the list if its id-label_id_offset is between 0 (inclusive) and max_num_classes (exclusive). If there are several items mapping to the same id in the label map, we will only keep the first one in the categories list. Args: label_map: a StringIntLabelMapProto or None. If None, a default categories list is created with max_num_classes categories. max_num_classes: maximum number of (consecutive) label indices to include. use_display_name: (boolean) choose whether to load 'display_name' field as category name. If False or if the display_name field does not exist, uses 'name' field as category names instead. Returns: categories: a list of dictionaries representing all possible categories. """ categories = [] list_of_ids_already_added = [] if not label_map: label_id_offset = 1 for class_id in range(max_num_classes): categories.append({ 'id': class_id + label_id_offset, 'name': 'category_{}'.format(class_id + label_id_offset) }) return categories for item in label_map.item: if not 0 < item.id <= max_num_classes: logging.info('Ignore item %d since it falls outside of requested ' 'label range.', item.id) continue if use_display_name and item.HasField('display_name'): name = item.display_name else: name = item.name if item.id not in list_of_ids_already_added: list_of_ids_already_added.append(item.id) categories.append({'id': item.id, 'name': name}) return categories
[ "def", "convert_label_map_to_categories", "(", "label_map", ",", "max_num_classes", ",", "use_display_name", "=", "True", ")", ":", "categories", "=", "[", "]", "list_of_ids_already_added", "=", "[", "]", "if", "not", "label_map", ":", "label_id_offset", "=", "1",...
https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/ce4e86107f36404cdb91c38bf8514983df5e5153/utils/label_map_util.py#L58-L105
YapengTian/TDAN-VSR-CVPR-2020
5ca05727f27570b7aa67d1ad5f3e87494e5a7dbd
solver.py
python
Solver._check_PSNR
(self, dataset, is_test=False)
return avr_psnr, avr_ssim, stats, outputs, names
Get the output of model with the input being 'dataset' then compute the PSNR between output and label. if 'is_test' is True, psnr and output of each image is also return for statistics and generate output image at test phase
Get the output of model with the input being 'dataset' then compute the PSNR between output and label.
[ "Get", "the", "output", "of", "model", "with", "the", "input", "being", "dataset", "then", "compute", "the", "PSNR", "between", "output", "and", "label", "." ]
def _check_PSNR(self, dataset, is_test=False): """ Get the output of model with the input being 'dataset' then compute the PSNR between output and label. if 'is_test' is True, psnr and output of each image is also return for statistics and generate output image at test phase """ # process one image per iter for test phase if is_test: batch_size = 1 else: batch_size = 1 # self.batch_size dataloader = DataLoader(dataset, batch_size=batch_size, shuffle=False, num_workers=1) avr_psnr = 0 avr_ssim = 0 # book keeping variables for test phase psnrs = [] # psnr for each image ssims = [] # ssim for each image proc_time = [] # processing time outputs = [] # output for each image names = [] for batch, sample in enumerate(dataloader): input_batch, label_batch, name = sample['lr'], sample['hr'], sample['im_name'] # Wrap with torch Variable input_batch, label_batch = self._wrap_variable(input_batch, label_batch, self.use_gpu) if is_test: start = time.time() if self.model_name in ['TDAN']: output_batch = chop_forward(input_batch, self.model, 4) #output_batch = chop_forward(input_batch, self.model, 4) #output_batch = forward_x8(input_batch, self.model).unsqueeze(0) #print(output_batch.size()) # _, lrs = self.model(input_batch) # output_batch = lrs[:, -1, :, :, :] else: output_batch = self.model(input_batch) elapsed_time = time.time() - start else: if self.model_name in ['TDAN']: #output_batch, _ = self.model(input_batch) output_batch = chop_forward(input_batch, self.model, 4) else: output_batch = self.model(input_batch) # ssim is calculated with the normalize (range [0, 1]) image ssim = pytorch_ssim.ssim(output_batch + 0.5, label_batch + 0.5, size_average=False) ssim = torch.sum(ssim.data) avr_ssim += ssim # calculate PSRN output = output_batch.data label = label_batch.data output = (output + 0.5) * 255 label = (label + 0.5) * 255 output = quantize(output, 255) label = quantize(label, 255) # diff = input - target output = output.squeeze(dim=0) label = label.squeeze(dim=0) psnr = self._comput_PSNR(output / 255.0, label / 255.0) # print(psnr) avr_psnr += psnr # save psnrs and outputs for statistics and generate image at test time if is_test: psnrs.append(psnr) ssims.append(ssim) proc_time.append(elapsed_time) np_output = output.cpu().numpy() outputs.append(np_output) names.append(name) epoch_size = len(dataset) avr_psnr /= epoch_size avr_ssim /= epoch_size stats = (psnrs, ssims, proc_time) return avr_psnr, avr_ssim, stats, outputs, names
[ "def", "_check_PSNR", "(", "self", ",", "dataset", ",", "is_test", "=", "False", ")", ":", "# process one image per iter for test phase", "if", "is_test", ":", "batch_size", "=", "1", "else", ":", "batch_size", "=", "1", "# self.batch_size", "dataloader", "=", "...
https://github.com/YapengTian/TDAN-VSR-CVPR-2020/blob/5ca05727f27570b7aa67d1ad5f3e87494e5a7dbd/solver.py#L266-L357
petercorke/robotics-toolbox-python
51aa8bbb3663a7c815f9880d538d61e7c85bc470
roboticstoolbox/tools/urdf/urdf.py
python
Joint.child
(self)
return self._child
str : The name of the child link.
str : The name of the child link.
[ "str", ":", "The", "name", "of", "the", "child", "link", "." ]
def child(self): """str : The name of the child link.""" return self._child
[ "def", "child", "(", "self", ")", ":", "return", "self", ".", "_child" ]
https://github.com/petercorke/robotics-toolbox-python/blob/51aa8bbb3663a7c815f9880d538d61e7c85bc470/roboticstoolbox/tools/urdf/urdf.py#L1331-L1333
aiidateam/aiida-core
c743a335480f8bb3a5e4ebd2463a31f9f3b9f9b2
aiida/engine/processes/calcjobs/calcjob.py
python
validate_stash_options
(stash_options: Any, _: Any)
return None
Validate the ``stash`` options.
Validate the ``stash`` options.
[ "Validate", "the", "stash", "options", "." ]
def validate_stash_options(stash_options: Any, _: Any) -> Optional[str]: """Validate the ``stash`` options.""" from aiida.common.datastructures import StashMode target_base = stash_options.get('target_base', None) source_list = stash_options.get('source_list', None) stash_mode = stash_options.get('mode', StashMode.COPY.value) if not isinstance(target_base, str) or not os.path.isabs(target_base): return f'`metadata.options.stash.target_base` should be an absolute filepath, got: {target_base}' if ( not isinstance(source_list, (list, tuple)) or any(not isinstance(src, str) or os.path.isabs(src) for src in source_list) ): port = 'metadata.options.stash.source_list' return f'`{port}` should be a list or tuple of relative filepaths, got: {source_list}' try: StashMode(stash_mode) except ValueError: port = 'metadata.options.stash.mode' return f'`{port}` should be a member of aiida.common.datastructures.StashMode, got: {stash_mode}' return None
[ "def", "validate_stash_options", "(", "stash_options", ":", "Any", ",", "_", ":", "Any", ")", "->", "Optional", "[", "str", "]", ":", "from", "aiida", ".", "common", ".", "datastructures", "import", "StashMode", "target_base", "=", "stash_options", ".", "get...
https://github.com/aiidateam/aiida-core/blob/c743a335480f8bb3a5e4ebd2463a31f9f3b9f9b2/aiida/engine/processes/calcjobs/calcjob.py#L110-L134
robinhood/faust
01b4c0ad8390221db71751d80001b0fd879291e2
faust/agents/agent.py
python
Agent.on_shared_partitions_assigned
(self, assigned: Set[TP])
Call when non-isolated partitions are assigned.
Call when non-isolated partitions are assigned.
[ "Call", "when", "non", "-", "isolated", "partitions", "are", "assigned", "." ]
async def on_shared_partitions_assigned(self, assigned: Set[TP]) -> None: """Call when non-isolated partitions are assigned.""" ...
[ "async", "def", "on_shared_partitions_assigned", "(", "self", ",", "assigned", ":", "Set", "[", "TP", "]", ")", "->", "None", ":", "..." ]
https://github.com/robinhood/faust/blob/01b4c0ad8390221db71751d80001b0fd879291e2/faust/agents/agent.py#L428-L430
eoyilmaz/stalker
a35c041b79d953d00dc2a09cf8206956ca269bef
stalker/models/version.py
python
Version._template_variables
(self)
return kwargs
variables used in rendering the filename template
variables used in rendering the filename template
[ "variables", "used", "in", "rendering", "the", "filename", "template" ]
def _template_variables(self): """variables used in rendering the filename template """ from stalker import Shot sequences = [] scenes = [] if isinstance(self.task, Shot): sequences = self.task.sequences scenes = self.task.scenes # get the parent tasks task = self.task parent_tasks = task.parents parent_tasks.append(task) kwargs = { 'project': self.task.project, 'sequences': sequences, 'scenes': scenes, 'sequence': self.task, 'shot': self.task, 'asset': self.task, 'task': self.task, 'parent_tasks': parent_tasks, 'version': self, 'type': self.type, 'extension': self.extension } return kwargs
[ "def", "_template_variables", "(", "self", ")", ":", "from", "stalker", "import", "Shot", "sequences", "=", "[", "]", "scenes", "=", "[", "]", "if", "isinstance", "(", "self", ".", "task", ",", "Shot", ")", ":", "sequences", "=", "self", ".", "task", ...
https://github.com/eoyilmaz/stalker/blob/a35c041b79d953d00dc2a09cf8206956ca269bef/stalker/models/version.py#L369-L398
buildbot/buildbot
b9c558217c72e4c2463eedc7ec6d56736f7b01a8
master/setup.py
python
define_plugin_entries
(groups)
return result
helper to all groups for plugins
helper to all groups for plugins
[ "helper", "to", "all", "groups", "for", "plugins" ]
def define_plugin_entries(groups): """ helper to all groups for plugins """ result = dict() for group, modules in groups: tempo = [] for module_name, names in modules: tempo.extend([define_plugin_entry(name, module_name) for name in names]) result[group] = tempo return result
[ "def", "define_plugin_entries", "(", "groups", ")", ":", "result", "=", "dict", "(", ")", "for", "group", ",", "modules", "in", "groups", ":", "tempo", "=", "[", "]", "for", "module_name", ",", "names", "in", "modules", ":", "tempo", ".", "extend", "("...
https://github.com/buildbot/buildbot/blob/b9c558217c72e4c2463eedc7ec6d56736f7b01a8/master/setup.py#L113-L126
openshift/openshift-tools
1188778e728a6e4781acf728123e5b356380fe6f
openshift/installer/vendored/openshift-ansible-3.10.0-0.29.0/roles/lib_vendored_deps/library/oc_adm_policy_group.py
python
RoleBinding.__init__
(self, content)
RoleBinding constructor
RoleBinding constructor
[ "RoleBinding", "constructor" ]
def __init__(self, content): '''RoleBinding constructor''' super(RoleBinding, self).__init__(content=content) self._subjects = None self._role_ref = None self._group_names = None self._user_names = None
[ "def", "__init__", "(", "self", ",", "content", ")", ":", "super", "(", "RoleBinding", ",", "self", ")", ".", "__init__", "(", "content", "=", "content", ")", "self", ".", "_subjects", "=", "None", "self", ".", "_role_ref", "=", "None", "self", ".", ...
https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/openshift/installer/vendored/openshift-ansible-3.10.0-0.29.0/roles/lib_vendored_deps/library/oc_adm_policy_group.py#L1514-L1520
liquidctl/liquidctl
73962574632f94050c2a75f517e929a29797b5e2
liquidctl/keyval.py
python
RuntimeStorage.__init__
(self, key_prefixes, backend=None)
[]
def __init__(self, key_prefixes, backend=None): if not backend: backend = _FilesystemBackend(key_prefixes) self._backend = backend
[ "def", "__init__", "(", "self", ",", "key_prefixes", ",", "backend", "=", "None", ")", ":", "if", "not", "backend", ":", "backend", "=", "_FilesystemBackend", "(", "key_prefixes", ")", "self", ".", "_backend", "=", "backend" ]
https://github.com/liquidctl/liquidctl/blob/73962574632f94050c2a75f517e929a29797b5e2/liquidctl/keyval.py#L179-L182
cisco-sas/kitty
cb0760989dcdfe079e43ac574d872d0b18953a32
kitty/model/low_level/aliases.py
python
Greater
(field, comp_value)
return Compare(field, '>', comp_value)
Condition applies if the value of the field is greater than the comp_value :rtype: :class:`~kitty.model.low_level.condition.Compare`
Condition applies if the value of the field is greater than the comp_value
[ "Condition", "applies", "if", "the", "value", "of", "the", "field", "is", "greater", "than", "the", "comp_value" ]
def Greater(field, comp_value): ''' Condition applies if the value of the field is greater than the comp_value :rtype: :class:`~kitty.model.low_level.condition.Compare` ''' return Compare(field, '>', comp_value)
[ "def", "Greater", "(", "field", ",", "comp_value", ")", ":", "return", "Compare", "(", "field", ",", "'>'", ",", "comp_value", ")" ]
https://github.com/cisco-sas/kitty/blob/cb0760989dcdfe079e43ac574d872d0b18953a32/kitty/model/low_level/aliases.py#L282-L288
wxWidgets/Phoenix
b2199e299a6ca6d866aa6f3d0888499136ead9d6
wx/lib/agw/xlsgrid.py
python
XLSTable.GetRawValue
(self, row, col)
return cell.raw_value
Returns the "raw" value for the cell content. :param `row`: the row in which this cell lives; :param `col`: the column in which this cell lives.
Returns the "raw" value for the cell content.
[ "Returns", "the", "raw", "value", "for", "the", "cell", "content", "." ]
def GetRawValue(self, row, col): """ Returns the "raw" value for the cell content. :param `row`: the row in which this cell lives; :param `col`: the column in which this cell lives. """ cell = self.cells[(row, col)] return cell.raw_value
[ "def", "GetRawValue", "(", "self", ",", "row", ",", "col", ")", ":", "cell", "=", "self", ".", "cells", "[", "(", "row", ",", "col", ")", "]", "return", "cell", ".", "raw_value" ]
https://github.com/wxWidgets/Phoenix/blob/b2199e299a6ca6d866aa6f3d0888499136ead9d6/wx/lib/agw/xlsgrid.py#L1802-L1811
daoluan/decode-Django
d46a858b45b56de48b0355f50dd9e45402d04cfd
Django-1.5.1/django/utils/translation/trans_real.py
python
blankout
(src, char)
return dot_re.sub(char, src)
Changes every non-whitespace character to the given char. Used in the templatize function.
Changes every non-whitespace character to the given char. Used in the templatize function.
[ "Changes", "every", "non", "-", "whitespace", "character", "to", "the", "given", "char", ".", "Used", "in", "the", "templatize", "function", "." ]
def blankout(src, char): """ Changes every non-whitespace character to the given char. Used in the templatize function. """ return dot_re.sub(char, src)
[ "def", "blankout", "(", "src", ",", "char", ")", ":", "return", "dot_re", ".", "sub", "(", "char", ",", "src", ")" ]
https://github.com/daoluan/decode-Django/blob/d46a858b45b56de48b0355f50dd9e45402d04cfd/Django-1.5.1/django/utils/translation/trans_real.py#L437-L442
thunlp/ERNIE
9a4ab4af54bccb70b4eb53cbfe71a2bc16b9e93f
code/run_typing.py
python
DataProcessor.get_labels
(self)
Gets the list of labels for this data set.
Gets the list of labels for this data set.
[ "Gets", "the", "list", "of", "labels", "for", "this", "data", "set", "." ]
def get_labels(self): """Gets the list of labels for this data set.""" raise NotImplementedError()
[ "def", "get_labels", "(", "self", ")", ":", "raise", "NotImplementedError", "(", ")" ]
https://github.com/thunlp/ERNIE/blob/9a4ab4af54bccb70b4eb53cbfe71a2bc16b9e93f/code/run_typing.py#L91-L93
morganstanley/treadmill
f18267c665baf6def4374d21170198f63ff1cde4
lib/python/treadmill/discovery.py
python
Discovery.sync
(self, watch=True)
Find matching endpoints and put them on the queue for processing. If watch is True, establish a watch on /apps for new changes, otherwise put termination signal into the queue.
Find matching endpoints and put them on the queue for processing.
[ "Find", "matching", "endpoints", "and", "put", "them", "on", "the", "queue", "for", "processing", "." ]
def sync(self, watch=True): """Find matching endpoints and put them on the queue for processing. If watch is True, establish a watch on /apps for new changes, otherwise put termination signal into the queue. """ watch_cb = None if watch: watch_cb = self.apps_watcher match = self.get_endpoints_zk(watch_cb=watch_cb) # let's read self.state only once as this func can be executed # simultaneously (it's a Zk callback func) state = set(self.state) created = match - state deleted = state - match for endpoint in created: _LOGGER.debug('added endpoint: %s', endpoint) hostport = self.resolve_endpoint(endpoint) self.queue.put((endpoint, hostport)) for endpoint in deleted: _LOGGER.debug('deleted endpoint: %s', endpoint) self.queue.put((endpoint, None)) self.state = match
[ "def", "sync", "(", "self", ",", "watch", "=", "True", ")", ":", "watch_cb", "=", "None", "if", "watch", ":", "watch_cb", "=", "self", ".", "apps_watcher", "match", "=", "self", ".", "get_endpoints_zk", "(", "watch_cb", "=", "watch_cb", ")", "# let's rea...
https://github.com/morganstanley/treadmill/blob/f18267c665baf6def4374d21170198f63ff1cde4/lib/python/treadmill/discovery.py#L67-L94
maciejczyzewski/neural-chessboard
b4a8906059fd61f1962828602cc7253a9881cd7a
utils.py
python
head
(msg)
return "\x1b[5;30;43m " + msg + " \x1b[0m"
[]
def head(msg): return "\x1b[5;30;43m " + msg + " \x1b[0m"
[ "def", "head", "(", "msg", ")", ":", "return", "\"\\x1b[5;30;43m \"", "+", "msg", "+", "\" \\x1b[0m\"" ]
https://github.com/maciejczyzewski/neural-chessboard/blob/b4a8906059fd61f1962828602cc7253a9881cd7a/utils.py#L30-L30
gluon/AbletonLive9_RemoteScripts
0c0db5e2e29bbed88c82bf327f54d4968d36937e
_Tools/stubout.py
python
StubOutForTesting.Set
(self, parent, child_name, new_child)
Replace child_name's old definition with new_child, in the context of the given parent. The parent could be a module when the child is a function at module scope. Or the parent could be a class when a class' method is being replaced. The named child is set to new_child, while the prior definition is saved away for later, when UnsetAll() is called. This method supports the case where child_name is a staticmethod or a classmethod of parent.
Replace child_name's old definition with new_child, in the context of the given parent. The parent could be a module when the child is a function at module scope. Or the parent could be a class when a class' method is being replaced. The named child is set to new_child, while the prior definition is saved away for later, when UnsetAll() is called. This method supports the case where child_name is a staticmethod or a classmethod of parent.
[ "Replace", "child_name", "s", "old", "definition", "with", "new_child", "in", "the", "context", "of", "the", "given", "parent", ".", "The", "parent", "could", "be", "a", "module", "when", "the", "child", "is", "a", "function", "at", "module", "scope", ".",...
def Set(self, parent, child_name, new_child): """Replace child_name's old definition with new_child, in the context of the given parent. The parent could be a module when the child is a function at module scope. Or the parent could be a class when a class' method is being replaced. The named child is set to new_child, while the prior definition is saved away for later, when UnsetAll() is called. This method supports the case where child_name is a staticmethod or a classmethod of parent. """ old_child = getattr(parent, child_name) old_attribute = parent.__dict__.get(child_name) if old_attribute is not None: if isinstance(old_attribute, staticmethod): old_child = staticmethod(old_child) elif isinstance(old_attribute, classmethod): old_child = classmethod(old_child.im_func) self.cache.append((parent, old_child, child_name)) setattr(parent, child_name, new_child)
[ "def", "Set", "(", "self", ",", "parent", ",", "child_name", ",", "new_child", ")", ":", "old_child", "=", "getattr", "(", "parent", ",", "child_name", ")", "old_attribute", "=", "parent", ".", "__dict__", ".", "get", "(", "child_name", ")", "if", "old_a...
https://github.com/gluon/AbletonLive9_RemoteScripts/blob/0c0db5e2e29bbed88c82bf327f54d4968d36937e/_Tools/stubout.py#L84-L102
danforthcenter/plantcv
aecd599d917884770aa0c7dec15bc9d1c53f36c4
plantcv/plantcv/spectral_index/spectral_index.py
python
ci_rededge
(hsi, distance=20)
Chlorophyll Index Red Edge. CI_REDEDGE = (R800 / R700) - 1 The theoretical range for CI_REDEDGE is [-1.0, Inf). Inputs: hsi = hyperspectral image (PlantCV Spectral_data instance) distance = how lenient to be if the required wavelengths are not available Returns: index_array = Index data as a Spectral_data instance :param hsi: __main__.Spectral_data :param distance: int :return index_array: __main__.Spectral_data
Chlorophyll Index Red Edge.
[ "Chlorophyll", "Index", "Red", "Edge", "." ]
def ci_rededge(hsi, distance=20): """Chlorophyll Index Red Edge. CI_REDEDGE = (R800 / R700) - 1 The theoretical range for CI_REDEDGE is [-1.0, Inf). Inputs: hsi = hyperspectral image (PlantCV Spectral_data instance) distance = how lenient to be if the required wavelengths are not available Returns: index_array = Index data as a Spectral_data instance :param hsi: __main__.Spectral_data :param distance: int :return index_array: __main__.Spectral_data """ if (float(hsi.max_wavelength) + distance) >= 800 and (float(hsi.min_wavelength) - distance) <= 700: r700_index = _find_closest(np.array([float(i) for i in hsi.wavelength_dict.keys()]), 700) r800_index = _find_closest(np.array([float(i) for i in hsi.wavelength_dict.keys()]), 800) r700 = (hsi.array_data[:, :, r700_index]) r800 = (hsi.array_data[:, :, r800_index]) # Naturally ranges from -1 to inf index_array_raw = (r800 / r700) - 1 return _package_index(hsi=hsi, raw_index=index_array_raw, method="CI_REDEDGE") else: fatal_error("Available wavelengths are not suitable for calculating CI_REDEDGE. Try increasing distance.")
[ "def", "ci_rededge", "(", "hsi", ",", "distance", "=", "20", ")", ":", "if", "(", "float", "(", "hsi", ".", "max_wavelength", ")", "+", "distance", ")", ">=", "800", "and", "(", "float", "(", "hsi", ".", "min_wavelength", ")", "-", "distance", ")", ...
https://github.com/danforthcenter/plantcv/blob/aecd599d917884770aa0c7dec15bc9d1c53f36c4/plantcv/plantcv/spectral_index/spectral_index.py#L169-L197
cloudera/impyla
0c736af4cad2bade9b8e313badc08ec50e81c948
impala/_thrift_gen/hive_metastore/ttypes.py
python
HeartbeatTxnRangeResponse.__ne__
(self, other)
return not (self == other)
[]
def __ne__(self, other): return not (self == other)
[ "def", "__ne__", "(", "self", ",", "other", ")", ":", "return", "not", "(", "self", "==", "other", ")" ]
https://github.com/cloudera/impyla/blob/0c736af4cad2bade9b8e313badc08ec50e81c948/impala/_thrift_gen/hive_metastore/ttypes.py#L8751-L8752
materialsproject/pymatgen
8128f3062a334a2edd240e4062b5b9bdd1ae6f58
pymatgen/electronic_structure/boltztrap2.py
python
BztTransportProperties.__init__
( self, BztInterpolator, temp_r=np.arange(100, 1400, 100), doping=None, npts_mu=4000, CRTA=1e-14, margin=None, save_bztTranspProps=False, load_bztTranspProps=False, fname="bztTranspProps.json.gz", )
Args: BztInterpolator: a BztInterpolator previously generated temp_r: numpy array of temperatures at which to calculate trasport properties doping: doping levels at which to calculate trasport properties. If provided, transport properties w.r.t. these doping levels are also computed. See compute_properties_doping() method for details. npts_mu: number of energy points at which to calculate trasport properties CRTA: constant value of the relaxation time save_bztTranspProps: Default False. If True all computed tranport properties will be stored in fname file. load_bztTranspProps: Default False. If True all computed tranport properties will be loaded from fname file. fname: File path where to save/load tranport properties. Upon creation, it contains properties tensors w.r.t. the chemical potential of size (len(temp_r),npts_mu,3,3): Conductivity_mu (S/m), Seebeck_mu (microV/K), Kappa_mu (W/(m*K)), Power_Factor_mu (milliW/K m); cond_Effective_mass_mu (m_e) calculated as Ref. Also: Carrier_conc_mu: carrier concentration of size (len(temp_r),npts_mu) Hall_carrier_conc_trace_mu: trace of Hall carrier concentration of size (len(temp_r),npts_mu) mu_r_eV: array of energies in eV and with E_fermi at 0.0 where all the properties are calculated. Example: bztTransp = BztTransportProperties(bztInterp,temp_r = np.arange(100,1400,100))
Args: BztInterpolator: a BztInterpolator previously generated temp_r: numpy array of temperatures at which to calculate trasport properties doping: doping levels at which to calculate trasport properties. If provided, transport properties w.r.t. these doping levels are also computed. See compute_properties_doping() method for details. npts_mu: number of energy points at which to calculate trasport properties CRTA: constant value of the relaxation time save_bztTranspProps: Default False. If True all computed tranport properties will be stored in fname file. load_bztTranspProps: Default False. If True all computed tranport properties will be loaded from fname file. fname: File path where to save/load tranport properties.
[ "Args", ":", "BztInterpolator", ":", "a", "BztInterpolator", "previously", "generated", "temp_r", ":", "numpy", "array", "of", "temperatures", "at", "which", "to", "calculate", "trasport", "properties", "doping", ":", "doping", "levels", "at", "which", "to", "ca...
def __init__( self, BztInterpolator, temp_r=np.arange(100, 1400, 100), doping=None, npts_mu=4000, CRTA=1e-14, margin=None, save_bztTranspProps=False, load_bztTranspProps=False, fname="bztTranspProps.json.gz", ): """ Args: BztInterpolator: a BztInterpolator previously generated temp_r: numpy array of temperatures at which to calculate trasport properties doping: doping levels at which to calculate trasport properties. If provided, transport properties w.r.t. these doping levels are also computed. See compute_properties_doping() method for details. npts_mu: number of energy points at which to calculate trasport properties CRTA: constant value of the relaxation time save_bztTranspProps: Default False. If True all computed tranport properties will be stored in fname file. load_bztTranspProps: Default False. If True all computed tranport properties will be loaded from fname file. fname: File path where to save/load tranport properties. Upon creation, it contains properties tensors w.r.t. the chemical potential of size (len(temp_r),npts_mu,3,3): Conductivity_mu (S/m), Seebeck_mu (microV/K), Kappa_mu (W/(m*K)), Power_Factor_mu (milliW/K m); cond_Effective_mass_mu (m_e) calculated as Ref. Also: Carrier_conc_mu: carrier concentration of size (len(temp_r),npts_mu) Hall_carrier_conc_trace_mu: trace of Hall carrier concentration of size (len(temp_r),npts_mu) mu_r_eV: array of energies in eV and with E_fermi at 0.0 where all the properties are calculated. Example: bztTransp = BztTransportProperties(bztInterp,temp_r = np.arange(100,1400,100)) """ self.dosweight = BztInterpolator.data.dosweight self.volume = BztInterpolator.data.get_volume() self.nelect = BztInterpolator.data.nelect self.efermi = BztInterpolator.data.fermi / units.eV if margin is None: margin = 9.0 * units.BOLTZMANN * temp_r.max() if load_bztTranspProps: self.load(fname) else: self.CRTA = CRTA self.temp_r = temp_r self.doping = doping self.epsilon, self.dos, self.vvdos, self.cdos = BL.BTPDOS( BztInterpolator.eband, BztInterpolator.vvband, npts=npts_mu, cband=BztInterpolator.cband, ) mur_indices = np.logical_and( self.epsilon > self.epsilon.min() + margin, self.epsilon < self.epsilon.max() - margin, ) self.mu_r = self.epsilon[mur_indices] self.mu_r_eV = self.mu_r / units.eV - self.efermi N, L0, L1, L2, Lm11 = BL.fermiintegrals( self.epsilon, self.dos, self.vvdos, mur=self.mu_r, Tr=temp_r, dosweight=self.dosweight, cdos=self.cdos, ) # Compute the Onsager coefficients from those Fermi integrals ( self.Conductivity_mu, self.Seebeck_mu, self.Kappa_mu, Hall_mu, ) = BL.calc_Onsager_coefficients(L0, L1, L2, self.mu_r, temp_r, self.volume, Lm11=Lm11) # Common properties rescaling self.Conductivity_mu *= CRTA # S / m self.Seebeck_mu *= 1e6 # microvolt / K self.Kappa_mu *= CRTA # W / (m K) self.Hall_carrier_conc_trace_mu = ( units.Coulomb * 1e-6 / (np.abs(Hall_mu[:, :, 0, 1, 2] + Hall_mu[:, :, 2, 0, 1] + Hall_mu[:, :, 1, 2, 0]) / 3) ) self.Carrier_conc_mu = (N + self.nelect) / (self.volume / (units.Meter / 100.0) ** 3) # Derived properties cond_eff_mass = np.zeros((len(self.temp_r), len(self.mu_r), 3, 3)) for t in range(len(self.temp_r)): for i in range(len(self.mu_r)): try: cond_eff_mass[t, i] = ( np.linalg.inv(self.Conductivity_mu[t, i]) * self.Carrier_conc_mu[t, i] * units.qe_SI ** 2 / units.me_SI * 1e6 ) except np.linalg.LinAlgError: pass self.Effective_mass_mu = cond_eff_mass * CRTA self.Power_Factor_mu = (self.Seebeck_mu @ self.Seebeck_mu) @ self.Conductivity_mu self.Power_Factor_mu *= 1e-9 # milliWatt / m / K**2 # self.props_as_dict() self.contain_props_doping = False if isinstance(doping, np.ndarray): self.compute_properties_doping(doping, temp_r) if save_bztTranspProps: self.save(fname)
[ "def", "__init__", "(", "self", ",", "BztInterpolator", ",", "temp_r", "=", "np", ".", "arange", "(", "100", ",", "1400", ",", "100", ")", ",", "doping", "=", "None", ",", "npts_mu", "=", "4000", ",", "CRTA", "=", "1e-14", ",", "margin", "=", "None...
https://github.com/materialsproject/pymatgen/blob/8128f3062a334a2edd240e4062b5b9bdd1ae6f58/pymatgen/electronic_structure/boltztrap2.py#L664-L794
veusz/veusz
5a1e2af5f24df0eb2a2842be51f2997c4999c7fb
veusz/windows/plotwindow.py
python
_
(text, disambiguation=None, context='PlotWindow')
return qt.QCoreApplication.translate(context, text, disambiguation)
Translate text.
Translate text.
[ "Translate", "text", "." ]
def _(text, disambiguation=None, context='PlotWindow'): """Translate text.""" return qt.QCoreApplication.translate(context, text, disambiguation)
[ "def", "_", "(", "text", ",", "disambiguation", "=", "None", ",", "context", "=", "'PlotWindow'", ")", ":", "return", "qt", ".", "QCoreApplication", ".", "translate", "(", "context", ",", "text", ",", "disambiguation", ")" ]
https://github.com/veusz/veusz/blob/5a1e2af5f24df0eb2a2842be51f2997c4999c7fb/veusz/windows/plotwindow.py#L34-L36
yt-project/yt
dc7b24f9b266703db4c843e329c6c8644d47b824
yt/frontends/gadget/simulation_handling.py
python
GadgetSimulation.__init__
(self, parameter_filename, find_outputs=False)
[]
def __init__(self, parameter_filename, find_outputs=False): self.simulation_type = "particle" self.dimensionality = 3 SimulationTimeSeries.__init__( self, parameter_filename, find_outputs=find_outputs )
[ "def", "__init__", "(", "self", ",", "parameter_filename", ",", "find_outputs", "=", "False", ")", ":", "self", ".", "simulation_type", "=", "\"particle\"", "self", ".", "dimensionality", "=", "3", "SimulationTimeSeries", ".", "__init__", "(", "self", ",", "pa...
https://github.com/yt-project/yt/blob/dc7b24f9b266703db4c843e329c6c8644d47b824/yt/frontends/gadget/simulation_handling.py#L52-L57
Yelp/clusterman
54beef89c01a2681aafd1fbb93b6ad5f6252d6cf
examples/clusterman_metrics/clusterman_metrics/boto_client.py
python
ClustermanMetricsBotoClient._extract_timestamp_and_value_from_items
(self, items)
return res
[]
def _extract_timestamp_and_value_from_items(self, items): try: res = [(item["timestamp"], item["value"]) for item in items] except KeyError: res = [(item["timestamp"], {k: v for k, v in item.items() if k not in RESERVED_KEYS},) for item in items] return res
[ "def", "_extract_timestamp_and_value_from_items", "(", "self", ",", "items", ")", ":", "try", ":", "res", "=", "[", "(", "item", "[", "\"timestamp\"", "]", ",", "item", "[", "\"value\"", "]", ")", "for", "item", "in", "items", "]", "except", "KeyError", ...
https://github.com/Yelp/clusterman/blob/54beef89c01a2681aafd1fbb93b6ad5f6252d6cf/examples/clusterman_metrics/clusterman_metrics/boto_client.py#L297-L302
eBay/Sequence-Semantic-Embedding
c2fff8c6f0a6d5931b8d40f5c95bb1c39ff93e92
tokenizer.py
python
encode
(text)
return ret
Encode a unicode string as a list of tokens. Args: text: a unicode string Returns: a list of tokens as Unicode strings
Encode a unicode string as a list of tokens.
[ "Encode", "a", "unicode", "string", "as", "a", "list", "of", "tokens", "." ]
def encode(text): """Encode a unicode string as a list of tokens. Args: text: a unicode string Returns: a list of tokens as Unicode strings """ if not text: return [] ret = [] token_start = 0 # Classify each character in the input string is_alnum = [c in _ALPHANUMERIC_CHAR_SET for c in text] for pos in xrange(1, len(text)): if is_alnum[pos] != is_alnum[pos - 1]: token = text[token_start:pos] if token != u" " or token_start == 0: ret.append(token) token_start = pos final_token = text[token_start:] ret.append(final_token) return ret
[ "def", "encode", "(", "text", ")", ":", "if", "not", "text", ":", "return", "[", "]", "ret", "=", "[", "]", "token_start", "=", "0", "# Classify each character in the input string", "is_alnum", "=", "[", "c", "in", "_ALPHANUMERIC_CHAR_SET", "for", "c", "in",...
https://github.com/eBay/Sequence-Semantic-Embedding/blob/c2fff8c6f0a6d5931b8d40f5c95bb1c39ff93e92/tokenizer.py#L68-L90
mila-iqia/myia
56774a39579b4ec4123f44843ad4ca688acc859b
myia/operations/prim_array_map.py
python
ArrayMapGradient.generate_graph
(self, absargs)
return g
Generate the gradient graph.
Generate the gradient graph.
[ "Generate", "the", "gradient", "graph", "." ]
def generate_graph(self, absargs): """Generate the gradient graph.""" g = Graph() nargs = len(absargs) - 1 params = [g.add_parameter() for _ in range(nargs + 1)] jf, *jargs = params f, *args = [g.apply(P.Jinv, p) for p in params] ret = g.apply(P.array_map, f, *args) b = Graph() dout = b.add_parameter() results = [] for i in range(nargs): func = Graph() fparams = [func.add_parameter() for _ in range(nargs + 1)] fparams[0].debug.name = f'{syms["grad_sens"]}out' fjparams = [func.apply(P.J, p) for p in fparams] call = func.apply(jf, *fjparams[1:]) bprop = func.apply(P.tuple_getitem, call, 1) sens = func.apply(bprop, fparams[0]) func.output = func.apply(P.tuple_getitem, sens, i + 1) result = b.apply(P.array_map, func, dout, *args) results.append(result) b.output = b.apply(P.make_tuple, newenv, newenv, *results) ret = g.apply(P.J, ret) g.output = g.apply(P.make_tuple, ret, b) b.flags.update(default_grad_flags) g.flags.update(default_grad_flags) return g
[ "def", "generate_graph", "(", "self", ",", "absargs", ")", ":", "g", "=", "Graph", "(", ")", "nargs", "=", "len", "(", "absargs", ")", "-", "1", "params", "=", "[", "g", ".", "add_parameter", "(", ")", "for", "_", "in", "range", "(", "nargs", "+"...
https://github.com/mila-iqia/myia/blob/56774a39579b4ec4123f44843ad4ca688acc859b/myia/operations/prim_array_map.py#L102-L136
harry159821/XiamiForLinuxProject
93d75d7652548d02ba386c961bc8afb5550a530e
bs4/element.py
python
PageElement.insert_before
(self, predecessor)
Makes the given element the immediate predecessor of this one. The two elements will have the same parent, and the given element will be immediately before this one.
Makes the given element the immediate predecessor of this one.
[ "Makes", "the", "given", "element", "the", "immediate", "predecessor", "of", "this", "one", "." ]
def insert_before(self, predecessor): """Makes the given element the immediate predecessor of this one. The two elements will have the same parent, and the given element will be immediately before this one. """ if self is predecessor: raise ValueError("Can't insert an element before itself.") parent = self.parent if parent is None: raise ValueError( "Element has no parent, so 'before' has no meaning.") # Extract first so that the index won't be screwed up if they # are siblings. if isinstance(predecessor, PageElement): predecessor.extract() index = parent.index(self) parent.insert(index, predecessor)
[ "def", "insert_before", "(", "self", ",", "predecessor", ")", ":", "if", "self", "is", "predecessor", ":", "raise", "ValueError", "(", "\"Can't insert an element before itself.\"", ")", "parent", "=", "self", ".", "parent", "if", "parent", "is", "None", ":", "...
https://github.com/harry159821/XiamiForLinuxProject/blob/93d75d7652548d02ba386c961bc8afb5550a530e/bs4/element.py#L263-L280
wistbean/learn_python3_spider
73c873f4845f4385f097e5057407d03dd37a117b
stackoverflow/venv/lib/python3.6/site-packages/twisted/spread/publish.py
python
_pubReady
(result, d2)
(internal)
(internal)
[ "(", "internal", ")" ]
def _pubReady(result, d2): '(internal)' result.callWhenActivated(d2.callback)
[ "def", "_pubReady", "(", "result", ",", "d2", ")", ":", "result", ".", "callWhenActivated", "(", "d2", ".", "callback", ")" ]
https://github.com/wistbean/learn_python3_spider/blob/73c873f4845f4385f097e5057407d03dd37a117b/stackoverflow/venv/lib/python3.6/site-packages/twisted/spread/publish.py#L140-L142
jgagneastro/coffeegrindsize
22661ebd21831dba4cf32bfc6ba59fe3d49f879c
App/dist/coffeegrindsize.app/Contents/Resources/lib/python3.7/scipy/optimize/zeros.py
python
_secant
(xvals, fvals)
return x2
Perform a secant step, taking a little care
Perform a secant step, taking a little care
[ "Perform", "a", "secant", "step", "taking", "a", "little", "care" ]
def _secant(xvals, fvals): """Perform a secant step, taking a little care""" # Secant has many "mathematically" equivalent formulations # x2 = x0 - (x1 - x0)/(f1 - f0) * f0 # = x1 - (x1 - x0)/(f1 - f0) * f1 # = (-x1 * f0 + x0 * f1) / (f1 - f0) # = (-f0 / f1 * x1 + x0) / (1 - f0 / f1) # = (-f1 / f0 * x0 + x1) / (1 - f1 / f0) x0, x1 = xvals[:2] f0, f1 = fvals[:2] if f0 == f1: return np.nan if np.abs(f1) > np.abs(f0): x2 = (-f0 / f1 * x1 + x0) / (1 - f0 / f1) else: x2 = (-f1 / f0 * x0 + x1) / (1 - f1 / f0) return x2
[ "def", "_secant", "(", "xvals", ",", "fvals", ")", ":", "# Secant has many \"mathematically\" equivalent formulations", "# x2 = x0 - (x1 - x0)/(f1 - f0) * f0", "# = x1 - (x1 - x0)/(f1 - f0) * f1", "# = (-x1 * f0 + x0 * f1) / (f1 - f0)", "# = (-f0 / f1 * x1 + x0) / (1 - f0 / f1)", ...
https://github.com/jgagneastro/coffeegrindsize/blob/22661ebd21831dba4cf32bfc6ba59fe3d49f879c/App/dist/coffeegrindsize.app/Contents/Resources/lib/python3.7/scipy/optimize/zeros.py#L905-L921
huawei-noah/Pretrained-Language-Model
d4694a134bdfacbaef8ff1d99735106bd3b3372b
DynaBERT/transformers/data/processors/glue.py
python
QqpProcessor.get_train_examples
(self, data_dir)
return self._create_examples( self._read_tsv(os.path.join(data_dir, "train.tsv")), "train")
See base class.
See base class.
[ "See", "base", "class", "." ]
def get_train_examples(self, data_dir): """See base class.""" return self._create_examples( self._read_tsv(os.path.join(data_dir, "train.tsv")), "train")
[ "def", "get_train_examples", "(", "self", ",", "data_dir", ")", ":", "return", "self", ".", "_create_examples", "(", "self", ".", "_read_tsv", "(", "os", ".", "path", ".", "join", "(", "data_dir", ",", "\"train.tsv\"", ")", ")", ",", "\"train\"", ")" ]
https://github.com/huawei-noah/Pretrained-Language-Model/blob/d4694a134bdfacbaef8ff1d99735106bd3b3372b/DynaBERT/transformers/data/processors/glue.py#L585-L588
mysql/mysql-utilities
08276b2258bf9739f53406b354b21195ff69a261
mysql/utilities/common/replication.py
python
Slave.get_executed_gtid_set
(self)
return ''
Get any events (gtids) executed Returns a string with the list of gtids in Executed_Gtid_Set. Note: an empty string is returned if the server is not acting as a slave.
Get any events (gtids) executed
[ "Get", "any", "events", "(", "gtids", ")", "executed" ]
def get_executed_gtid_set(self): """Get any events (gtids) executed Returns a string with the list of gtids in Executed_Gtid_Set. Note: an empty string is returned if the server is not acting as a slave. """ res = self.get_status() if res: return res[0][_EXECUTED_GTID_SET] return ''
[ "def", "get_executed_gtid_set", "(", "self", ")", ":", "res", "=", "self", ".", "get_status", "(", ")", "if", "res", ":", "return", "res", "[", "0", "]", "[", "_EXECUTED_GTID_SET", "]", "return", "''" ]
https://github.com/mysql/mysql-utilities/blob/08276b2258bf9739f53406b354b21195ff69a261/mysql/utilities/common/replication.py#L1354-L1366
gwastro/pycbc
1e1c85534b9dba8488ce42df693230317ca63dea
pycbc/transforms.py
python
read_transforms_from_config
(cp, section="transforms")
return order_transforms(trans)
Returns a list of PyCBC transform instances for a section in the given configuration file. If the transforms are nested (i.e., the output of one transform is the input of another), the returned list will be sorted by the order of the nests. Parameters ---------- cp : WorflowConfigParser An open config file to read. section : {"transforms", string} Prefix on section names from which to retrieve the transforms. Returns ------- list A list of the parsed transforms.
Returns a list of PyCBC transform instances for a section in the given configuration file.
[ "Returns", "a", "list", "of", "PyCBC", "transform", "instances", "for", "a", "section", "in", "the", "given", "configuration", "file", "." ]
def read_transforms_from_config(cp, section="transforms"): """Returns a list of PyCBC transform instances for a section in the given configuration file. If the transforms are nested (i.e., the output of one transform is the input of another), the returned list will be sorted by the order of the nests. Parameters ---------- cp : WorflowConfigParser An open config file to read. section : {"transforms", string} Prefix on section names from which to retrieve the transforms. Returns ------- list A list of the parsed transforms. """ trans = [] for subsection in cp.get_subsections(section): name = cp.get_opt_tag(section, "name", subsection) t = transforms[name].from_config(cp, section, subsection) trans.append(t) return order_transforms(trans)
[ "def", "read_transforms_from_config", "(", "cp", ",", "section", "=", "\"transforms\"", ")", ":", "trans", "=", "[", "]", "for", "subsection", "in", "cp", ".", "get_subsections", "(", "section", ")", ":", "name", "=", "cp", ".", "get_opt_tag", "(", "sectio...
https://github.com/gwastro/pycbc/blob/1e1c85534b9dba8488ce42df693230317ca63dea/pycbc/transforms.py#L2478-L2503
pygments/pygments
cd3ad20dfc8a6cb43e2c0b22b14446dcc0a554d7
pygments/formatters/html.py
python
HtmlFormatter._wrap_code
(self, inner)
[]
def _wrap_code(self, inner): yield 0, '<code>' yield from inner yield 0, '</code>'
[ "def", "_wrap_code", "(", "self", ",", "inner", ")", ":", "yield", "0", ",", "'<code>'", "yield", "from", "inner", "yield", "0", ",", "'</code>'" ]
https://github.com/pygments/pygments/blob/cd3ad20dfc8a6cb43e2c0b22b14446dcc0a554d7/pygments/formatters/html.py#L821-L824
playframework/play1
0ecac3bc2421ae2dbec27a368bf671eda1c9cba5
python/Lib/mhlib.py
python
MH.listallfolders
(self)
return self.listallsubfolders('')
Return the names of all folders and subfolders, recursively.
Return the names of all folders and subfolders, recursively.
[ "Return", "the", "names", "of", "all", "folders", "and", "subfolders", "recursively", "." ]
def listallfolders(self): """Return the names of all folders and subfolders, recursively.""" return self.listallsubfolders('')
[ "def", "listallfolders", "(", "self", ")", ":", "return", "self", ".", "listallsubfolders", "(", "''", ")" ]
https://github.com/playframework/play1/blob/0ecac3bc2421ae2dbec27a368bf671eda1c9cba5/python/Lib/mhlib.py#L179-L181
kuri65536/python-for-android
26402a08fc46b09ef94e8d7a6bbc3a54ff9d0891
python-build/python-libs/gdata/src/gdata/youtube/service.py
python
YouTubeService.AddPlaylistVideoEntryToPlaylist
( self, playlist_uri, video_id, custom_video_title=None, custom_video_description=None)
return self.Post(playlist_video_entry, playlist_uri, converter=gdata.youtube.YouTubePlaylistVideoEntryFromString)
Add a video entry to a playlist, optionally providing a custom title and description. Needs authentication. Args: playlist_uri: A string representing the URI of the playlist to which this video entry is to be added. video_id: A string representing the ID of the video entry to add. custom_video_title: An optional string representing a custom title for the video (only shown on the playlist). custom_video_description: An optional string representing a custom description for the video (only shown on the playlist). Returns: A YouTubePlaylistVideoEntry if successfully posted.
Add a video entry to a playlist, optionally providing a custom title and description.
[ "Add", "a", "video", "entry", "to", "a", "playlist", "optionally", "providing", "a", "custom", "title", "and", "description", "." ]
def AddPlaylistVideoEntryToPlaylist( self, playlist_uri, video_id, custom_video_title=None, custom_video_description=None): """Add a video entry to a playlist, optionally providing a custom title and description. Needs authentication. Args: playlist_uri: A string representing the URI of the playlist to which this video entry is to be added. video_id: A string representing the ID of the video entry to add. custom_video_title: An optional string representing a custom title for the video (only shown on the playlist). custom_video_description: An optional string representing a custom description for the video (only shown on the playlist). Returns: A YouTubePlaylistVideoEntry if successfully posted. """ playlist_video_entry = gdata.youtube.YouTubePlaylistVideoEntry( atom_id=atom.Id(text=video_id)) if custom_video_title: playlist_video_entry.title = atom.Title(text=custom_video_title) if custom_video_description: playlist_video_entry.description = gdata.youtube.Description( text=custom_video_description) return self.Post(playlist_video_entry, playlist_uri, converter=gdata.youtube.YouTubePlaylistVideoEntryFromString)
[ "def", "AddPlaylistVideoEntryToPlaylist", "(", "self", ",", "playlist_uri", ",", "video_id", ",", "custom_video_title", "=", "None", ",", "custom_video_description", "=", "None", ")", ":", "playlist_video_entry", "=", "gdata", ".", "youtube", ".", "YouTubePlaylistVide...
https://github.com/kuri65536/python-for-android/blob/26402a08fc46b09ef94e8d7a6bbc3a54ff9d0891/python-build/python-libs/gdata/src/gdata/youtube/service.py#L982-L1011
demisto/content
5c664a65b992ac8ca90ac3f11b1b2cdf11ee9b07
Packs/McAfee_ESM-v10/Integrations/McAfee_ESM-v10/McAfee_ESM-v10.py
python
NitroESM.get_users
(self)
return self.cmdquery(cmd, query)
get all user's names
get all user's names
[ "get", "all", "user", "s", "names" ]
def get_users(self): """get all user's names""" cmd = 'userGetUserList' query = json.dumps({"authPW": {"value": self.passwd}}) return self.cmdquery(cmd, query)
[ "def", "get_users", "(", "self", ")", ":", "cmd", "=", "'userGetUserList'", "query", "=", "json", ".", "dumps", "(", "{", "\"authPW\"", ":", "{", "\"value\"", ":", "self", ".", "passwd", "}", "}", ")", "return", "self", ".", "cmdquery", "(", "cmd", "...
https://github.com/demisto/content/blob/5c664a65b992ac8ca90ac3f11b1b2cdf11ee9b07/Packs/McAfee_ESM-v10/Integrations/McAfee_ESM-v10/McAfee_ESM-v10.py#L445-L450
schissmantics/yolo-tf2
90e14f1bf8a0a87b32367aa1411e417fa9800167
yolo_tf2/utils/common.py
python
add_xml_path
(xml_file, path)
Add a path element to the xml file and save. Args: xml_file: .xml file path. path: str, path to add. Returns: None
Add a path element to the xml file and save. Args: xml_file: .xml file path. path: str, path to add.
[ "Add", "a", "path", "element", "to", "the", "xml", "file", "and", "save", ".", "Args", ":", "xml_file", ":", ".", "xml", "file", "path", ".", "path", ":", "str", "path", "to", "add", "." ]
def add_xml_path(xml_file, path): """ Add a path element to the xml file and save. Args: xml_file: .xml file path. path: str, path to add. Returns: None """ tree = ElementTree.parse(xml_file) top = tree.getroot() folder_tag = tree.find('folder') folder_tag.text = path file_name_tag = tree.find('filename') path_tag = SubElement(top, 'path') path_tag.text = get_abs_path(folder_tag.text, file_name_tag.text) rough_string = ElementTree.tostring(top, 'utf8') root = etree.fromstring(rough_string) pretty = etree.tostring(root, pretty_print=True, encoding='utf-8').replace( ' '.encode(), '\t'.encode() ) os.remove(xml_file) with open(xml_file, 'wb') as output: output.write(pretty)
[ "def", "add_xml_path", "(", "xml_file", ",", "path", ")", ":", "tree", "=", "ElementTree", ".", "parse", "(", "xml_file", ")", "top", "=", "tree", ".", "getroot", "(", ")", "folder_tag", "=", "tree", ".", "find", "(", "'folder'", ")", "folder_tag", "."...
https://github.com/schissmantics/yolo-tf2/blob/90e14f1bf8a0a87b32367aa1411e417fa9800167/yolo_tf2/utils/common.py#L245-L269
eth-sri/debin
9abb5215b54077da1e9479bfcbc56cd860aac370
py/elftools/dwarf/lineprogram.py
python
LineProgram.get_entries
(self)
return self._decoded_entries
Get the decoded entries for this line program. Return a list of LineProgramEntry objects. Note that this contains more information than absolutely required for the line table. The line table can be easily extracted from the list of entries by looking only at entries with non-None state. The extra information is mainly for the purposes of display with readelf and debugging.
Get the decoded entries for this line program. Return a list of LineProgramEntry objects. Note that this contains more information than absolutely required for the line table. The line table can be easily extracted from the list of entries by looking only at entries with non-None state. The extra information is mainly for the purposes of display with readelf and debugging.
[ "Get", "the", "decoded", "entries", "for", "this", "line", "program", ".", "Return", "a", "list", "of", "LineProgramEntry", "objects", ".", "Note", "that", "this", "contains", "more", "information", "than", "absolutely", "required", "for", "the", "line", "tabl...
def get_entries(self): """ Get the decoded entries for this line program. Return a list of LineProgramEntry objects. Note that this contains more information than absolutely required for the line table. The line table can be easily extracted from the list of entries by looking only at entries with non-None state. The extra information is mainly for the purposes of display with readelf and debugging. """ if self._decoded_entries is None: self._decoded_entries = self._decode_line_program() return self._decoded_entries
[ "def", "get_entries", "(", "self", ")", ":", "if", "self", ".", "_decoded_entries", "is", "None", ":", "self", ".", "_decoded_entries", "=", "self", ".", "_decode_line_program", "(", ")", "return", "self", ".", "_decoded_entries" ]
https://github.com/eth-sri/debin/blob/9abb5215b54077da1e9479bfcbc56cd860aac370/py/elftools/dwarf/lineprogram.py#L104-L115
klen/aioauth-client
7672e66053cfd6973261f40741916d2fd52ff97e
aioauth_client/__init__.py
python
User.__init__
(self, **info)
Initialize self data.
Initialize self data.
[ "Initialize", "self", "data", "." ]
def __init__(self, **info): """Initialize self data.""" for attr in self.__slots__: setattr(self, attr, info.get(attr))
[ "def", "__init__", "(", "self", ",", "*", "*", "info", ")", ":", "for", "attr", "in", "self", ".", "__slots__", ":", "setattr", "(", "self", ",", "attr", ",", "info", ".", "get", "(", "attr", ")", ")" ]
https://github.com/klen/aioauth-client/blob/7672e66053cfd6973261f40741916d2fd52ff97e/aioauth_client/__init__.py#L39-L42
khanhnamle1994/natural-language-processing
01d450d5ac002b0156ef4cf93a07cb508c1bcdc5
assignment1/.env/lib/python2.7/site-packages/pkg_resources/__init__.py
python
MemoizedZipManifests.load
(self, path)
return self[path].manifest
Load a manifest at path or return a suitable manifest already loaded.
Load a manifest at path or return a suitable manifest already loaded.
[ "Load", "a", "manifest", "at", "path", "or", "return", "a", "suitable", "manifest", "already", "loaded", "." ]
def load(self, path): """ Load a manifest at path or return a suitable manifest already loaded. """ path = os.path.normpath(path) mtime = os.stat(path).st_mtime if path not in self or self[path].mtime != mtime: manifest = self.build(path) self[path] = self.manifest_mod(manifest, mtime) return self[path].manifest
[ "def", "load", "(", "self", ",", "path", ")", ":", "path", "=", "os", ".", "path", ".", "normpath", "(", "path", ")", "mtime", "=", "os", ".", "stat", "(", "path", ")", ".", "st_mtime", "if", "path", "not", "in", "self", "or", "self", "[", "pat...
https://github.com/khanhnamle1994/natural-language-processing/blob/01d450d5ac002b0156ef4cf93a07cb508c1bcdc5/assignment1/.env/lib/python2.7/site-packages/pkg_resources/__init__.py#L1669-L1680
openshift/openshift-tools
1188778e728a6e4781acf728123e5b356380fe6f
openshift/installer/vendored/openshift-ansible-3.9.40/roles/lib_vendored_deps/library/oc_adm_policy_group.py
python
RoleBinding.update_group_name
(self, inc_group_name)
return True
update a groupname
update a groupname
[ "update", "a", "groupname" ]
def update_group_name(self, inc_group_name): ''' update a groupname ''' try: # pylint: disable=no-member index = self.group_names.index(inc_group_name) except ValueError as _: return self.add_group_names(inc_group_name) self.group_names[index] = inc_group_name return True
[ "def", "update_group_name", "(", "self", ",", "inc_group_name", ")", ":", "try", ":", "# pylint: disable=no-member", "index", "=", "self", ".", "group_names", ".", "index", "(", "inc_group_name", ")", "except", "ValueError", "as", "_", ":", "return", "self", "...
https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/openshift/installer/vendored/openshift-ansible-3.9.40/roles/lib_vendored_deps/library/oc_adm_policy_group.py#L1685-L1695
arsaboo/homeassistant-config
53c998986fbe84d793a0b174757154ab30e676e4
custom_components/hacs/repositories/integration.py
python
HacsIntegration.localpath
(self)
return f"{self.hacs.system.config_path}/custom_components/{self.data.domain}"
Return localpath.
Return localpath.
[ "Return", "localpath", "." ]
def localpath(self): """Return localpath.""" return f"{self.hacs.system.config_path}/custom_components/{self.data.domain}"
[ "def", "localpath", "(", "self", ")", ":", "return", "f\"{self.hacs.system.config_path}/custom_components/{self.data.domain}\"" ]
https://github.com/arsaboo/homeassistant-config/blob/53c998986fbe84d793a0b174757154ab30e676e4/custom_components/hacs/repositories/integration.py#L30-L32
python-openxml/python-docx
36cac78de080d412e9e50d56c2784e33655cad59
docx/oxml/section.py
python
CT_SectPr.add_footerReference
(self, type_, rId)
return footerReference
Return newly added CT_HdrFtrRef element of *type_* with *rId*. The element tag is `w:footerReference`.
Return newly added CT_HdrFtrRef element of *type_* with *rId*.
[ "Return", "newly", "added", "CT_HdrFtrRef", "element", "of", "*", "type_", "*", "with", "*", "rId", "*", "." ]
def add_footerReference(self, type_, rId): """Return newly added CT_HdrFtrRef element of *type_* with *rId*. The element tag is `w:footerReference`. """ footerReference = self._add_footerReference() footerReference.type_ = type_ footerReference.rId = rId return footerReference
[ "def", "add_footerReference", "(", "self", ",", "type_", ",", "rId", ")", ":", "footerReference", "=", "self", ".", "_add_footerReference", "(", ")", "footerReference", ".", "type_", "=", "type_", "footerReference", ".", "rId", "=", "rId", "return", "footerRef...
https://github.com/python-openxml/python-docx/blob/36cac78de080d412e9e50d56c2784e33655cad59/docx/oxml/section.py#L75-L83
plastex/plastex
af1628719b50cf25fbe80f16a3e100d566e9bc32
plasTeX/__init__.py
python
Macro.config
(self)
return self.ownerDocument.config
Shortcut to the document config
Shortcut to the document config
[ "Shortcut", "to", "the", "document", "config" ]
def config(self): """ Shortcut to the document config """ return self.ownerDocument.config
[ "def", "config", "(", "self", ")", ":", "return", "self", ".", "ownerDocument", ".", "config" ]
https://github.com/plastex/plastex/blob/af1628719b50cf25fbe80f16a3e100d566e9bc32/plasTeX/__init__.py#L194-L196
googleads/google-ads-python
2a1d6062221f6aad1992a6bcca0e7e4a93d2db86
google/ads/googleads/v7/services/services/dynamic_search_ads_search_term_view_service/transports/grpc.py
python
DynamicSearchAdsSearchTermViewServiceGrpcTransport.create_channel
( cls, host: str = "googleads.googleapis.com", credentials: credentials.Credentials = None, scopes: Optional[Sequence[str]] = None, **kwargs, )
return grpc_helpers.create_channel( host, credentials=credentials, scopes=scopes or cls.AUTH_SCOPES, **kwargs, )
Create and return a gRPC channel object. Args: address (Optionsl[str]): The host for the channel to use. credentials (Optional[~.Credentials]): The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment. scopes (Optional[Sequence[str]]): A optional list of scopes needed for this service. These are only used when credentials are not specified and are passed to :func:`google.auth.default`. kwargs (Optional[dict]): Keyword arguments, which are passed to the channel creation. Returns: grpc.Channel: A gRPC channel object.
Create and return a gRPC channel object. Args: address (Optionsl[str]): The host for the channel to use. credentials (Optional[~.Credentials]): The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment. scopes (Optional[Sequence[str]]): A optional list of scopes needed for this service. These are only used when credentials are not specified and are passed to :func:`google.auth.default`. kwargs (Optional[dict]): Keyword arguments, which are passed to the channel creation. Returns: grpc.Channel: A gRPC channel object.
[ "Create", "and", "return", "a", "gRPC", "channel", "object", ".", "Args", ":", "address", "(", "Optionsl", "[", "str", "]", ")", ":", "The", "host", "for", "the", "channel", "to", "use", ".", "credentials", "(", "Optional", "[", "~", ".", "Credentials"...
def create_channel( cls, host: str = "googleads.googleapis.com", credentials: credentials.Credentials = None, scopes: Optional[Sequence[str]] = None, **kwargs, ) -> grpc.Channel: """Create and return a gRPC channel object. Args: address (Optionsl[str]): The host for the channel to use. credentials (Optional[~.Credentials]): The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment. scopes (Optional[Sequence[str]]): A optional list of scopes needed for this service. These are only used when credentials are not specified and are passed to :func:`google.auth.default`. kwargs (Optional[dict]): Keyword arguments, which are passed to the channel creation. Returns: grpc.Channel: A gRPC channel object. """ return grpc_helpers.create_channel( host, credentials=credentials, scopes=scopes or cls.AUTH_SCOPES, **kwargs, )
[ "def", "create_channel", "(", "cls", ",", "host", ":", "str", "=", "\"googleads.googleapis.com\"", ",", "credentials", ":", "credentials", ".", "Credentials", "=", "None", ",", "scopes", ":", "Optional", "[", "Sequence", "[", "str", "]", "]", "=", "None", ...
https://github.com/googleads/google-ads-python/blob/2a1d6062221f6aad1992a6bcca0e7e4a93d2db86/google/ads/googleads/v7/services/services/dynamic_search_ads_search_term_view_service/transports/grpc.py#L185-L213
googlefonts/gftools
8ad55dd4d7e38729524329c79f236476f1576e67
bin/gftools-build-vf.py
python
printR
(prt)
Print in red
Print in red
[ "Print", "in", "red" ]
def printR(prt): """ Print in red """ print("\033[91m {}\033[00m".format(prt))
[ "def", "printR", "(", "prt", ")", ":", "print", "(", "\"\\033[91m {}\\033[00m\"", ".", "format", "(", "prt", ")", ")" ]
https://github.com/googlefonts/gftools/blob/8ad55dd4d7e38729524329c79f236476f1576e67/bin/gftools-build-vf.py#L94-L98
FraBle/python-duckling
e6a34192e35fd4fc287b4bc93c938fcd5c2d9024
duckling/wrapper.py
python
DucklingWrapper.parse_leven_product
(self, input_str)
return self._parse(input_str, dim=Dim.LEVENPRODUCT)
Parses input with Duckling for occurences of products. Args: input_str: An input string, e.g. '5 cups of sugar'. Returns: A preprocessed list of results (dicts) from Duckling output. For example: [ { "dim": "leven-product", "end": 15, "start": 10, "value": { "value": "sugar" }, "text": "sugar" } ]
Parses input with Duckling for occurences of products.
[ "Parses", "input", "with", "Duckling", "for", "occurences", "of", "products", "." ]
def parse_leven_product(self, input_str): """Parses input with Duckling for occurences of products. Args: input_str: An input string, e.g. '5 cups of sugar'. Returns: A preprocessed list of results (dicts) from Duckling output. For example: [ { "dim": "leven-product", "end": 15, "start": 10, "value": { "value": "sugar" }, "text": "sugar" } ] """ return self._parse(input_str, dim=Dim.LEVENPRODUCT)
[ "def", "parse_leven_product", "(", "self", ",", "input_str", ")", ":", "return", "self", ".", "_parse", "(", "input_str", ",", "dim", "=", "Dim", ".", "LEVENPRODUCT", ")" ]
https://github.com/FraBle/python-duckling/blob/e6a34192e35fd4fc287b4bc93c938fcd5c2d9024/duckling/wrapper.py#L609-L632
LumaPictures/pymel
fa88a3f4fa18e09bb8aa9bdf4dab53d984bada72
pymel/core/datatypes.py
python
EulerRotation.__iadd__
(self, other)
u.__iadd__(v) <==> u += v In place addition of u and v, see __add__
u.__iadd__(v) <==> u += v In place addition of u and v, see __add__
[ "u", ".", "__iadd__", "(", "v", ")", "<", "==", ">", "u", "+", "=", "v", "In", "place", "addition", "of", "u", "and", "v", "see", "__add__" ]
def __iadd__(self, other): """ u.__iadd__(v) <==> u += v In place addition of u and v, see __add__ """ try: return self.__class__(self.__add__(other)) except: return NotImplemented
[ "def", "__iadd__", "(", "self", ",", "other", ")", ":", "try", ":", "return", "self", ".", "__class__", "(", "self", ".", "__add__", "(", "other", ")", ")", "except", ":", "return", "NotImplemented" ]
https://github.com/LumaPictures/pymel/blob/fa88a3f4fa18e09bb8aa9bdf4dab53d984bada72/pymel/core/datatypes.py#L2990-L2996
beancount/beancount
cb3526a1af95b3b5be70347470c381b5a86055fe
beancount/utils/misc_utils.py
python
idify
(string)
return string
Replace characters objectionable for a filename with underscores. Args: string: Any string. Returns: The input string, with offending characters replaced.
Replace characters objectionable for a filename with underscores.
[ "Replace", "characters", "objectionable", "for", "a", "filename", "with", "underscores", "." ]
def idify(string): """Replace characters objectionable for a filename with underscores. Args: string: Any string. Returns: The input string, with offending characters replaced. """ for sfrom, sto in [(r'[ \(\)]+', '_'), (r'_*\._*', '.')]: string = re.sub(sfrom, sto, string) string = string.strip('_') return string
[ "def", "idify", "(", "string", ")", ":", "for", "sfrom", ",", "sto", "in", "[", "(", "r'[ \\(\\)]+'", ",", "'_'", ")", ",", "(", "r'_*\\._*'", ",", "'.'", ")", "]", ":", "string", "=", "re", ".", "sub", "(", "sfrom", ",", "sto", ",", "string", ...
https://github.com/beancount/beancount/blob/cb3526a1af95b3b5be70347470c381b5a86055fe/beancount/utils/misc_utils.py#L285-L297
openstack/neutron
fb229fb527ac8b95526412f7762d90826ac41428
neutron/cmd/status.py
python
setup_conf
(conf=cfg.CONF)
return conf
Setup the cfg for the status check utility. Use separate setup_conf for the utility because there are many options from the main config that do not apply during checks.
Setup the cfg for the status check utility.
[ "Setup", "the", "cfg", "for", "the", "status", "check", "utility", "." ]
def setup_conf(conf=cfg.CONF): """Setup the cfg for the status check utility. Use separate setup_conf for the utility because there are many options from the main config that do not apply during checks. """ neutron_conf_base.register_core_common_config_opts(conf) neutron_conf_service.register_service_opts( neutron_conf_service.SERVICE_OPTS, cfg.CONF) db_options.set_defaults(conf) return conf
[ "def", "setup_conf", "(", "conf", "=", "cfg", ".", "CONF", ")", ":", "neutron_conf_base", ".", "register_core_common_config_opts", "(", "conf", ")", "neutron_conf_service", ".", "register_service_opts", "(", "neutron_conf_service", ".", "SERVICE_OPTS", ",", "cfg", "...
https://github.com/openstack/neutron/blob/fb229fb527ac8b95526412f7762d90826ac41428/neutron/cmd/status.py#L47-L58
leo-editor/leo-editor
383d6776d135ef17d73d935a2f0ecb3ac0e99494
leo/plugins/cursesGui2.py
python
LeoCursesGui.createCursesMinibuffer
(self, c, form)
Create the curses minibuffer widget in the given curses Form.
Create the curses minibuffer widget in the given curses Form.
[ "Create", "the", "curses", "minibuffer", "widget", "in", "the", "given", "curses", "Form", "." ]
def createCursesMinibuffer(self, c, form): """Create the curses minibuffer widget in the given curses Form.""" trace = False class MiniBufferBox(npyscreen.BoxTitle): """An npyscreen class representing Leo's minibuffer, with binding.""" # pylint: disable=used-before-assignment _contained_widget = LeoMiniBuffer how_exited = None box = form.add(MiniBufferBox, name='Mini-buffer', max_height=3) assert isinstance(box, MiniBufferBox) # Link and check... widgets = box._my_widgets assert len(widgets) == 1 w = widgets[0] if trace: g.trace('\nMINI', w, '\nBOX', box) assert isinstance(w, LeoMiniBuffer), repr(w) assert isinstance(c.frame, CoreFrame), repr(c.frame) assert c.frame.miniBufferWidget is None wrapper = MiniBufferWrapper(c, 'minibuffer', w) assert wrapper.widget == w, repr(wrapper.widget) c.frame.miniBufferWidget = wrapper # Inject the box into the wrapper wrapper.box = box # Inject the wrapper for get_focus. box.leo_wrapper = wrapper w.leo_c = c w.leo_wrapper = wrapper
[ "def", "createCursesMinibuffer", "(", "self", ",", "c", ",", "form", ")", ":", "trace", "=", "False", "class", "MiniBufferBox", "(", "npyscreen", ".", "BoxTitle", ")", ":", "\"\"\"An npyscreen class representing Leo's minibuffer, with binding.\"\"\"", "# pylint: disable=u...
https://github.com/leo-editor/leo-editor/blob/383d6776d135ef17d73d935a2f0ecb3ac0e99494/leo/plugins/cursesGui2.py#L1384-L1413
pypa/pipenv
b21baade71a86ab3ee1429f71fbc14d4f95fb75d
pipenv/vendor/vistir/compat.py
python
_invalid_utf8_indexes
(bytes)
return skips
[]
def _invalid_utf8_indexes(bytes): skips = [] i = 0 len_bytes = len(bytes) while i < len_bytes: c1 = bytes[i] if c1 < 0x80: # U+0000 - U+007F - 7 bits i += 1 continue try: c2 = bytes[i + 1] if (c1 & 0xE0 == 0xC0) and (c2 & 0xC0 == 0x80): # U+0080 - U+07FF - 11 bits c = ((c1 & 0x1F) << 6) | (c2 & 0x3F) if c < 0x80: # pragma: no cover # Overlong encoding skips.extend([i, i + 1]) # pragma: no cover i += 2 continue c3 = bytes[i + 2] if (c1 & 0xF0 == 0xE0) and (c2 & 0xC0 == 0x80) and (c3 & 0xC0 == 0x80): # U+0800 - U+FFFF - 16 bits c = ((((c1 & 0x0F) << 6) | (c2 & 0x3F)) << 6) | (c3 & 0x3F) if (c < 0x800) or (0xD800 <= c <= 0xDFFF): # Overlong encoding or surrogate. skips.extend([i, i + 1, i + 2]) i += 3 continue c4 = bytes[i + 3] if ( (c1 & 0xF8 == 0xF0) and (c2 & 0xC0 == 0x80) and (c3 & 0xC0 == 0x80) and (c4 & 0xC0 == 0x80) ): # U+10000 - U+10FFFF - 21 bits c = ((((((c1 & 0x0F) << 6) | (c2 & 0x3F)) << 6) | (c3 & 0x3F)) << 6) | ( c4 & 0x3F ) if (c < 0x10000) or (c > 0x10FFFF): # pragma: no cover # Overlong encoding or invalid code point. skips.extend([i, i + 1, i + 2, i + 3]) i += 4 continue except IndexError: pass skips.append(i) i += 1 return skips
[ "def", "_invalid_utf8_indexes", "(", "bytes", ")", ":", "skips", "=", "[", "]", "i", "=", "0", "len_bytes", "=", "len", "(", "bytes", ")", "while", "i", "<", "len_bytes", ":", "c1", "=", "bytes", "[", "i", "]", "if", "c1", "<", "0x80", ":", "# U+...
https://github.com/pypa/pipenv/blob/b21baade71a86ab3ee1429f71fbc14d4f95fb75d/pipenv/vendor/vistir/compat.py#L313-L362
MingtaoFu/gliding_vertex
c4470140265140e118725b80a81efe68e44e10af
maskrcnn_benchmark/modeling/matcher.py
python
Matcher.__init__
(self, high_threshold, low_threshold, allow_low_quality_matches=False)
Args: high_threshold (float): quality values greater than or equal to this value are candidate matches. low_threshold (float): a lower quality threshold used to stratify matches into three levels: 1) matches >= high_threshold 2) BETWEEN_THRESHOLDS matches in [low_threshold, high_threshold) 3) BELOW_LOW_THRESHOLD matches in [0, low_threshold) allow_low_quality_matches (bool): if True, produce additional matches for predictions that have only low-quality match candidates. See set_low_quality_matches_ for more details.
Args: high_threshold (float): quality values greater than or equal to this value are candidate matches. low_threshold (float): a lower quality threshold used to stratify matches into three levels: 1) matches >= high_threshold 2) BETWEEN_THRESHOLDS matches in [low_threshold, high_threshold) 3) BELOW_LOW_THRESHOLD matches in [0, low_threshold) allow_low_quality_matches (bool): if True, produce additional matches for predictions that have only low-quality match candidates. See set_low_quality_matches_ for more details.
[ "Args", ":", "high_threshold", "(", "float", ")", ":", "quality", "values", "greater", "than", "or", "equal", "to", "this", "value", "are", "candidate", "matches", ".", "low_threshold", "(", "float", ")", ":", "a", "lower", "quality", "threshold", "used", ...
def __init__(self, high_threshold, low_threshold, allow_low_quality_matches=False): """ Args: high_threshold (float): quality values greater than or equal to this value are candidate matches. low_threshold (float): a lower quality threshold used to stratify matches into three levels: 1) matches >= high_threshold 2) BETWEEN_THRESHOLDS matches in [low_threshold, high_threshold) 3) BELOW_LOW_THRESHOLD matches in [0, low_threshold) allow_low_quality_matches (bool): if True, produce additional matches for predictions that have only low-quality match candidates. See set_low_quality_matches_ for more details. """ assert low_threshold <= high_threshold self.high_threshold = high_threshold self.low_threshold = low_threshold self.allow_low_quality_matches = allow_low_quality_matches
[ "def", "__init__", "(", "self", ",", "high_threshold", ",", "low_threshold", ",", "allow_low_quality_matches", "=", "False", ")", ":", "assert", "low_threshold", "<=", "high_threshold", "self", ".", "high_threshold", "=", "high_threshold", "self", ".", "low_threshol...
https://github.com/MingtaoFu/gliding_vertex/blob/c4470140265140e118725b80a81efe68e44e10af/maskrcnn_benchmark/modeling/matcher.py#L23-L40
thinkle/gourmet
8af29c8ded24528030e5ae2ea3461f61c1e5a575
gourmet/plugins/import_export/pdf_plugin/page_drawer.py
python
PageDrawer.on_realize
(self, widget: 'PdfPageDrawer')
[]
def on_realize(self, widget: 'PdfPageDrawer'): # TODO: refactor this function out # self.gc = widget.window.new_gc() #self.gc.set_line_attributes(3, Gdk.LINE_ON_OFF_DASH, # Gdk.CAP_ROUND, Gdk.JOIN_ROUND) pass
[ "def", "on_realize", "(", "self", ",", "widget", ":", "'PdfPageDrawer'", ")", ":", "# TODO: refactor this function out", "# self.gc = widget.window.new_gc()", "#self.gc.set_line_attributes(3, Gdk.LINE_ON_OFF_DASH,", "# Gdk.CAP_ROUND, Gdk.JOIN_ROUND)", "pass" ]
https://github.com/thinkle/gourmet/blob/8af29c8ded24528030e5ae2ea3461f61c1e5a575/gourmet/plugins/import_export/pdf_plugin/page_drawer.py#L40-L45
ShreyAmbesh/Traffic-Rule-Violation-Detection-System
ae0c327ce014ce6a427da920b5798a0d4bbf001e
meta_architectures/ssd_meta_arch.py
python
SSDMetaArch.preprocess
(self, inputs)
Feature-extractor specific preprocessing. SSD meta architecture uses a default clip_window of [0, 0, 1, 1] during post-processing. On calling `preprocess` method, clip_window gets updated based on `true_image_shapes` returned by `image_resizer_fn`. Args: inputs: a [batch, height_in, width_in, channels] float tensor representing a batch of images with values between 0 and 255.0. Returns: preprocessed_inputs: a [batch, height_out, width_out, channels] float tensor representing a batch of images. true_image_shapes: int32 tensor of shape [batch, 3] where each row is of the form [height, width, channels] indicating the shapes of true images in the resized images, as resized images can be padded with zeros. Raises: ValueError: if inputs tensor does not have type tf.float32
Feature-extractor specific preprocessing.
[ "Feature", "-", "extractor", "specific", "preprocessing", "." ]
def preprocess(self, inputs): """Feature-extractor specific preprocessing. SSD meta architecture uses a default clip_window of [0, 0, 1, 1] during post-processing. On calling `preprocess` method, clip_window gets updated based on `true_image_shapes` returned by `image_resizer_fn`. Args: inputs: a [batch, height_in, width_in, channels] float tensor representing a batch of images with values between 0 and 255.0. Returns: preprocessed_inputs: a [batch, height_out, width_out, channels] float tensor representing a batch of images. true_image_shapes: int32 tensor of shape [batch, 3] where each row is of the form [height, width, channels] indicating the shapes of true images in the resized images, as resized images can be padded with zeros. Raises: ValueError: if inputs tensor does not have type tf.float32 """ if inputs.dtype is not tf.float32: raise ValueError('`preprocess` expects a tf.float32 tensor') with tf.name_scope('Preprocessor'): # TODO: revisit whether to always use batch size as # the number of parallel iterations vs allow for dynamic batching. outputs = shape_utils.static_or_dynamic_map_fn( self._image_resizer_fn, elems=inputs, dtype=[tf.float32, tf.int32]) resized_inputs = outputs[0] true_image_shapes = outputs[1] return (self._feature_extractor.preprocess(resized_inputs), true_image_shapes)
[ "def", "preprocess", "(", "self", ",", "inputs", ")", ":", "if", "inputs", ".", "dtype", "is", "not", "tf", ".", "float32", ":", "raise", "ValueError", "(", "'`preprocess` expects a tf.float32 tensor'", ")", "with", "tf", ".", "name_scope", "(", "'Preprocessor...
https://github.com/ShreyAmbesh/Traffic-Rule-Violation-Detection-System/blob/ae0c327ce014ce6a427da920b5798a0d4bbf001e/meta_architectures/ssd_meta_arch.py#L223-L258
pymedusa/Medusa
1405fbb6eb8ef4d20fcca24c32ddca52b11f0f38
ext/soupsieve/css_parser.py
python
CSSParser.parse_pseudo_open
(self, sel, name, has_selector, iselector, index)
return has_selector
Parse pseudo with opening bracket.
Parse pseudo with opening bracket.
[ "Parse", "pseudo", "with", "opening", "bracket", "." ]
def parse_pseudo_open(self, sel, name, has_selector, iselector, index): """Parse pseudo with opening bracket.""" flags = FLG_PSEUDO | FLG_OPEN if name == ':not': flags |= FLG_NOT if name == ':has': flags |= FLG_RELATIVE sel.selectors.append(self.parse_selectors(iselector, index, flags)) has_selector = True return has_selector
[ "def", "parse_pseudo_open", "(", "self", ",", "sel", ",", "name", ",", "has_selector", ",", "iselector", ",", "index", ")", ":", "flags", "=", "FLG_PSEUDO", "|", "FLG_OPEN", "if", "name", "==", "':not'", ":", "flags", "|=", "FLG_NOT", "if", "name", "==",...
https://github.com/pymedusa/Medusa/blob/1405fbb6eb8ef4d20fcca24c32ddca52b11f0f38/ext/soupsieve/css_parser.py#L704-L715
pyglet/pyglet
2833c1df902ca81aeeffa786c12e7e87d402434b
pyglet/media/player.py
python
Player.on_driver_reset
(self)
The audio driver has been reset, by default this will kill the current audio player and create a new one, and requeue the buffers. Any buffers that may have been queued in a player will be resubmitted. It will continue from from the last buffers submitted, not played and may cause sync issues if using video. :event:
The audio driver has been reset, by default this will kill the current audio player and create a new one, and requeue the buffers. Any buffers that may have been queued in a player will be resubmitted. It will continue from from the last buffers submitted, not played and may cause sync issues if using video.
[ "The", "audio", "driver", "has", "been", "reset", "by", "default", "this", "will", "kill", "the", "current", "audio", "player", "and", "create", "a", "new", "one", "and", "requeue", "the", "buffers", ".", "Any", "buffers", "that", "may", "have", "been", ...
def on_driver_reset(self): """The audio driver has been reset, by default this will kill the current audio player and create a new one, and requeue the buffers. Any buffers that may have been queued in a player will be resubmitted. It will continue from from the last buffers submitted, not played and may cause sync issues if using video. :event: """ if self._audio_player: self._audio_player.on_driver_reset() # Voice has been changed, will need to reset all options on the voice. for attr in ('volume', 'min_distance', 'max_distance', 'position', 'pitch', 'cone_orientation', 'cone_inner_angle', 'cone_outer_angle', 'cone_outer_gain'): value = getattr(self, attr) setattr(self, attr, value) if self._playing: self._audio_player.play()
[ "def", "on_driver_reset", "(", "self", ")", ":", "if", "self", ".", "_audio_player", ":", "self", ".", "_audio_player", ".", "on_driver_reset", "(", ")", "# Voice has been changed, will need to reset all options on the voice.", "for", "attr", "in", "(", "'volume'", ",...
https://github.com/pyglet/pyglet/blob/2833c1df902ca81aeeffa786c12e7e87d402434b/pyglet/media/player.py#L629-L647
zulip/zulip
19f891968de50d43920af63526c823bdd233cdee
zerver/lib/push_notifications.py
python
get_message_payload
( user_profile: UserProfile, message: Message, mentioned_user_group_id: Optional[int] = None, mentioned_user_group_name: Optional[str] = None, )
return data
Common fields for `message` payloads, for all platforms.
Common fields for `message` payloads, for all platforms.
[ "Common", "fields", "for", "message", "payloads", "for", "all", "platforms", "." ]
def get_message_payload( user_profile: UserProfile, message: Message, mentioned_user_group_id: Optional[int] = None, mentioned_user_group_name: Optional[str] = None, ) -> Dict[str, Any]: """Common fields for `message` payloads, for all platforms.""" data = get_base_payload(user_profile) # `sender_id` is preferred, but some existing versions use `sender_email`. data["sender_id"] = message.sender.id data["sender_email"] = message.sender.email if mentioned_user_group_id is not None: assert mentioned_user_group_name is not None data["mentioned_user_group_id"] = mentioned_user_group_id data["mentioned_user_group_name"] = mentioned_user_group_name if message.recipient.type == Recipient.STREAM: data["recipient_type"] = "stream" data["stream"] = get_display_recipient(message.recipient) data["topic"] = message.topic_name() elif message.recipient.type == Recipient.HUDDLE: data["recipient_type"] = "private" data["pm_users"] = huddle_users(message.recipient.id) else: # Recipient.PERSONAL data["recipient_type"] = "private" return data
[ "def", "get_message_payload", "(", "user_profile", ":", "UserProfile", ",", "message", ":", "Message", ",", "mentioned_user_group_id", ":", "Optional", "[", "int", "]", "=", "None", ",", "mentioned_user_group_name", ":", "Optional", "[", "str", "]", "=", "None",...
https://github.com/zulip/zulip/blob/19f891968de50d43920af63526c823bdd233cdee/zerver/lib/push_notifications.py#L697-L724
openshift/openshift-tools
1188778e728a6e4781acf728123e5b356380fe6f
openshift/installer/vendored/openshift-ansible-3.9.14-1/roles/lib_vendored_deps/library/oc_service.py
python
Service.add_portal_ip
(self, pip)
add cluster ip
add cluster ip
[ "add", "cluster", "ip" ]
def add_portal_ip(self, pip): '''add cluster ip''' self.put(Service.portal_ip, pip)
[ "def", "add_portal_ip", "(", "self", ",", "pip", ")", ":", "self", ".", "put", "(", "Service", ".", "portal_ip", ",", "pip", ")" ]
https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/openshift/installer/vendored/openshift-ansible-3.9.14-1/roles/lib_vendored_deps/library/oc_service.py#L1662-L1664
openatx/uiautomator2
a6ebc2446a8babb4ce14dc62cfdb5590ea95c709
uiautomator2/__init__.py
python
_AppMixIn._pidof_app
(self, package_name)
Return pid of package name
Return pid of package name
[ "Return", "pid", "of", "package", "name" ]
def _pidof_app(self, package_name): """ Return pid of package name """ text = self.http.get('/pidof/' + package_name).text if text.isdigit(): return int(text)
[ "def", "_pidof_app", "(", "self", ",", "package_name", ")", ":", "text", "=", "self", ".", "http", ".", "get", "(", "'/pidof/'", "+", "package_name", ")", ".", "text", "if", "text", ".", "isdigit", "(", ")", ":", "return", "int", "(", "text", ")" ]
https://github.com/openatx/uiautomator2/blob/a6ebc2446a8babb4ce14dc62cfdb5590ea95c709/uiautomator2/__init__.py#L1314-L1320
leancloud/satori
701caccbd4fe45765001ca60435c0cb499477c03
satori-rules/plugin/libs/redis/client.py
python
StrictRedis.pfmerge
(self, dest, *sources)
return self.execute_command('PFMERGE', dest, *sources)
Merge N different HyperLogLogs into a single one.
Merge N different HyperLogLogs into a single one.
[ "Merge", "N", "different", "HyperLogLogs", "into", "a", "single", "one", "." ]
def pfmerge(self, dest, *sources): "Merge N different HyperLogLogs into a single one." return self.execute_command('PFMERGE', dest, *sources)
[ "def", "pfmerge", "(", "self", ",", "dest", ",", "*", "sources", ")", ":", "return", "self", ".", "execute_command", "(", "'PFMERGE'", ",", "dest", ",", "*", "sources", ")" ]
https://github.com/leancloud/satori/blob/701caccbd4fe45765001ca60435c0cb499477c03/satori-rules/plugin/libs/redis/client.py#L1842-L1844
codelv/enaml-native
04c3a015bcd649f374c5ecd98fcddba5e4fbdbdc
src/enamlnative/core/bridge.py
python
tag_object_with_id
(obj)
Generate and assign a id for the object
Generate and assign a id for the object
[ "Generate", "and", "assign", "a", "id", "for", "the", "object" ]
def tag_object_with_id(obj): """ Generate and assign a id for the object""" obj.__id__ = generate_id() CACHE[obj.__id__] = obj
[ "def", "tag_object_with_id", "(", "obj", ")", ":", "obj", ".", "__id__", "=", "generate_id", "(", ")", "CACHE", "[", "obj", ".", "__id__", "]", "=", "obj" ]
https://github.com/codelv/enaml-native/blob/04c3a015bcd649f374c5ecd98fcddba5e4fbdbdc/src/enamlnative/core/bridge.py#L57-L60