query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
set is mutable and dangerous.
def function1(value={1}): print(value)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set():", "def set():\n pass", "def Set(self) -> None:", "def __set__(self, obj, value):\r\n pass", "def set(x):\n pass", "def set(self, key, value):", "def set(self, key, value):", "def set(self, U):\n pass", "def set(self, U):\n pass", "def f_set(self, data):\n ...
[ "0.837998", "0.8050189", "0.76336277", "0.7309809", "0.7295644", "0.7043105", "0.7043105", "0.7029955", "0.7029955", "0.68462026", "0.6810316", "0.6722299", "0.66905844", "0.6632549", "0.6594598", "0.6581449", "0.6524981", "0.63941556", "0.6374605", "0.6370601", "0.63417166",...
0.0
-1
Escape value for commaseparated list
def list_escape(s): return re.sub(r'[\\,]', _escape_char, s)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def quote_list(the_list):\n return [\"'%s'\" % element for element in the_list]", "def _format_list_for_query(input_list):\n return (\n \", \".join(input_list).replace(\" \", \"\").replace(\"'\", \"\").replace(\",\", \"%2C\")\n )", "def escape_value(value: OptionValueType) -> Option...
[ "0.6734296", "0.64581853", "0.6446276", "0.64394754", "0.63908434", "0.6385253", "0.63293046", "0.632233", "0.61730325", "0.59699094", "0.59477973", "0.5917379", "0.5887457", "0.5872731", "0.58519614", "0.58464056", "0.5803603", "0.58012146", "0.579517", "0.57884943", "0.5786...
0.68377125
0
Convert DistinguishedName dict to '/'separated string.
def render_name(name_att_list): res = [''] for k, v in name_att_list: v = dn_escape(v) res.append("%s=%s" % (k, v)) res.append('') return '/'.join(res)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_dn(dn):\n if re.match(\"^/.*\", dn):\n return dn\n\n new_dn = \"\"\n attrs = dn.split(\",\")\n for attr in attrs:\n prm_tuple = attr.split(\"=\")\n k = prm_tuple[0].strip()\n v = prm_tuple[1].strip()\n new_dn = new_dn + f'/{k}={v}'\n return new_dn", "...
[ "0.6659733", "0.5775696", "0.5740528", "0.5423116", "0.54046327", "0.5284252", "0.52661365", "0.5201889", "0.5192248", "0.51429164", "0.50932664", "0.5080492", "0.5076293", "0.5024254", "0.50174654", "0.5016909", "0.5004144", "0.50006694", "0.4990777", "0.4978432", "0.4943308...
0.53524345
5
Parse argument value with function if string.
def maybe_parse(val, parse_func): if val is None: return [] if isinstance(val, (bytes, str)): return parse_func(val) if isinstance(val, dict): return list(val.items()) if isinstance(val, (list, tuple)): return list(val) return val
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def eval_arg(arg_value, arg_name=''):\n if arg_name.lower().endswith('_list') and isinstance(arg_value, str):\n return [eval_arg(cell) for cell in arg_value.split(',')]\n if not isinstance(arg_value, str):\n return arg_value\n if arg_value.lower() in ['true', 'false']:\n return eval(a...
[ "0.6599658", "0.65680563", "0.65047354", "0.64847267", "0.6464504", "0.6307335", "0.62872803", "0.60615987", "0.6032944", "0.58954966", "0.58332956", "0.58204687", "0.5797649", "0.5789056", "0.5745152", "0.5726418", "0.57198304", "0.57167447", "0.568619", "0.568619", "0.56850...
0.53076184
62
Load certificate info from existing certificate or certificate request.
def load_from_existing(self, obj): self.subject = self.extract_name(obj.subject) for ext in obj.extensions: crit = ext.critical extobj = ext.value if ext.oid == ExtensionOID.BASIC_CONSTRAINTS: if not crit: raise InvalidCertificate("BASIC_CONSTRAINTS must be critical") self.ca = extobj.ca self.path_length = None if self.ca: self.path_length = extobj.path_length elif ext.oid == ExtensionOID.KEY_USAGE: if not crit: raise InvalidCertificate("KEY_USAGE must be critical") self.usage += self.extract_key_usage(extobj) elif ext.oid == ExtensionOID.SUBJECT_ALTERNATIVE_NAME: self.san = self.extract_gnames(extobj) elif ext.oid == ExtensionOID.EXTENDED_KEY_USAGE: self.usage += self.extract_xkey_usage(extobj) elif ext.oid == ExtensionOID.AUTHORITY_INFORMATION_ACCESS: for ad in extobj: if not isinstance(ad.access_location, x509.UniformResourceIdentifier): InvalidCertificate("Unsupported access_location: %s" % (ad.access_location,)) url = as_unicode(ad.access_location.value) if ad.access_method == AuthorityInformationAccessOID.CA_ISSUERS: self.issuer_urls.append(url) elif ad.access_method == AuthorityInformationAccessOID.OCSP: self.ocsp_urls.append(url) else: raise InvalidCertificate("Unsupported access_method: %s" % (ad.access_method,)) elif ext.oid == ExtensionOID.CRL_DISTRIBUTION_POINTS: for dp in extobj: if dp.relative_name: raise InvalidCertificate("DistributionPoint.relative_name not supported") if dp.crl_issuer: raise InvalidCertificate("DistributionPoint.crl_issuer not supported") if dp.reasons: raise InvalidCertificate("DistributionPoint.reasons not supported") for gn in self.extract_gnames(dp.full_name): if gn.startswith('uri:'): self.crl_urls.append(gn[4:]) else: raise InvalidCertificate("Unsupported DistributionPoint: %s" % (gn,)) elif ext.oid == ExtensionOID.NAME_CONSTRAINTS: self.permit_subtrees = self.extract_gnames(extobj.permitted_subtrees) self.exclude_subtrees = self.extract_gnames(extobj.excluded_subtrees) elif ext.oid == ExtensionOID.SUBJECT_KEY_IDENTIFIER: pass elif ext.oid == ExtensionOID.AUTHORITY_KEY_IDENTIFIER: pass elif ext.oid == ExtensionOID.OCSP_NO_CHECK: self.ocsp_nocheck = True elif ext.oid == ExtensionOID.TLS_FEATURE: for tls_feature_code in extobj: if tls_feature_code == x509.TLSFeatureType.status_request: self.ocsp_must_staple = True elif tls_feature_code == x509.TLSFeatureType.status_request_v2: self.ocsp_must_staple_v2 = True else: raise InvalidCertificate("Unsupported TLSFeature: %r" % (tls_feature_code,)) else: raise InvalidCertificate("Unsupported extension in CSR: %s" % (ext,))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_x509_cert(url, httpc, spec2key, **get_args):\n try:\n r = httpc(\"GET\", url, allow_redirects=True, **get_args)\n if r.status_code == 200:\n cert = str(r.text)\n try:\n public_key = spec2key[cert] # If I've already seen it\n except KeyError...
[ "0.6680185", "0.63726574", "0.63267094", "0.6285823", "0.6274304", "0.62612367", "0.6248355", "0.6233824", "0.62313014", "0.61848396", "0.6153183", "0.6125429", "0.61140054", "0.59716755", "0.59682465", "0.5947671", "0.58962196", "0.58797115", "0.5856209", "0.5856209", "0.585...
0.5833314
21
Walk oid list, return keywords.
def extract_xkey_usage(self, ext): oidmap = {v: k for k, v in XKU_CODE_TO_OID.items()} res = [] for oid in ext: if oid in oidmap: res.append(oidmap[oid]) else: raise InvalidCertificate("Unsupported ExtendedKeyUsage oid: %s" % (oid,)) return res
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_keywords(self):\n keywords = [] \n for keyword in self.watsonLanguageModel['keywords'][:self.entitySizeLimit]: \n keywords.append(keyword['text'])\n return keywords", "def get_keywords(self):\r\n\t\treturn list(self.keyword_headlines().keys())", "def extract_keywor...
[ "0.59176874", "0.58475524", "0.56898886", "0.56249386", "0.5622464", "0.55950075", "0.5594749", "0.5539701", "0.55360544", "0.54705125", "0.5462367", "0.5412044", "0.53875583", "0.53866786", "0.5362733", "0.52585196", "0.524303", "0.5239646", "0.5229351", "0.517999", "0.51752...
0.0
-1
Extract list of tags from KeyUsage extension.
def extract_key_usage(self, ext): res = [] fields = KU_FIELDS[:] # "error-on-access", real funny if not ext.key_agreement: fields.remove('encipher_only') fields.remove('decipher_only') for k in fields: val = getattr(ext, k, False) if val: res.append(k) return res
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_xkey_usage(self, ext):\n oidmap = {v: k for k, v in XKU_CODE_TO_OID.items()}\n res = []\n for oid in ext:\n if oid in oidmap:\n res.append(oidmap[oid])\n else:\n raise InvalidCertificate(\"Unsupported ExtendedKeyUsage oid: %s\" % ...
[ "0.6921014", "0.6244223", "0.60213065", "0.594296", "0.59360904", "0.59154725", "0.59044653", "0.5891674", "0.5891674", "0.58631593", "0.5841936", "0.57997465", "0.5775625", "0.5767615", "0.57545197", "0.5743227", "0.5717393", "0.5711848", "0.5693686", "0.5669996", "0.5638222...
0.6967917
0
Convert Name object to shortcutdict.
def extract_name(self, name): name_oid2code_map = {v: k for k, v in DN_CODE_TO_OID.items()} res = [] for att in name: if att.oid not in name_oid2code_map: raise InvalidCertificate("Unsupported RDN: %s" % (att,)) desc = name_oid2code_map[att.oid] val = as_unicode(att.value) res.append((desc, val)) return res
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _to_dict(self, remove_name=True):\n keys = [\"name\", \"path\", \"type\", \"mode\", \"description\"]\n if remove_name:\n keys.remove(\"name\")\n result = {key: getattr(self, key) for key in keys}\n return _remove_empty_values(result)", "def process_shortcut(s):\n if ...
[ "0.5776113", "0.57499915", "0.5587667", "0.556973", "0.5420494", "0.53735536", "0.5343546", "0.5342723", "0.5337498", "0.53041375", "0.5202565", "0.50983745", "0.5079809", "0.50716364", "0.5070442", "0.50446194", "0.5030284", "0.5026418", "0.5009997", "0.4993586", "0.49922198...
0.0
-1
Convert list of GeneralNames to list of prefixed strings.
def extract_gnames(self, ext): res = [] for gn in ext: if isinstance(gn, x509.RFC822Name): res.append('email:' + as_unicode(gn.value)) elif isinstance(gn, x509.DNSName): res.append('dns:' + as_unicode(gn.value)) elif isinstance(gn, x509.UniformResourceIdentifier): res.append('uri:' + as_unicode(gn.value)) elif isinstance(gn, x509.IPAddress): res.append('ip:' + str(gn.value)) elif isinstance(gn, x509.DirectoryName): val = self.extract_name(gn.value) res.append('dn:' + render_name(val)) else: raise InvalidCertificate("Unsupported subjectAltName type: %s" % (gn,)) return res
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def original_names(names):\n if len(names) > 0 and isinstance(names[0], (list, tuple)):\n names = [x[0] for x in names]\n\n return [re.sub('_+$', '', x) for x in names]", "def standardize_many(self, names: list[str]) -> list[str]:\n assert type(names) == list\n return [self.standardize...
[ "0.6417263", "0.6408999", "0.6287097", "0.61460066", "0.6118145", "0.6083461", "0.60616726", "0.60493654", "0.6008381", "0.5945094", "0.59157145", "0.59041774", "0.5835183", "0.5815753", "0.5810204", "0.57882947", "0.57405", "0.5714124", "0.568949", "0.56647664", "0.56575066"...
0.54241467
33
Create Name object from subject's DistinguishedName.
def load_name(self, name_att_list): attlist = [] got = set() for k, v in name_att_list: if k in got and k not in DN_ALLOW_MULTIPLE: raise InvalidCertificate("Multiple Name keys not allowed: %s" % (k,)) oid = DN_CODE_TO_OID[k] n = x509.NameAttribute(oid, as_unicode(v)) attlist.append(n) return x509.Name(attlist)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create(subdomain, subject_type_or_type_name, subject_name, author):\n return Subject(key_name='%s:%s' % (subdomain, subject_name),\n type=get_name(subject_type_or_type_name), author=author)", "def get_name(self):\n return self.load_name(self.subject)", "def create_subjec...
[ "0.6041832", "0.57824373", "0.5740667", "0.56460947", "0.5608916", "0.5546563", "0.5349921", "0.5217777", "0.51690304", "0.51497644", "0.51314163", "0.5014414", "0.4994642", "0.49935788", "0.49472374", "0.49472374", "0.48983237", "0.4867557", "0.48653823", "0.4858505", "0.485...
0.45507523
50
Create Name object from subject's DistinguishedName.
def get_name(self): return self.load_name(self.subject)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create(subdomain, subject_type_or_type_name, subject_name, author):\n return Subject(key_name='%s:%s' % (subdomain, subject_name),\n type=get_name(subject_type_or_type_name), author=author)", "def create_subject(name=\"Basket Weaving\"):\n subj = Subject(name=name)\n subj.s...
[ "0.6042233", "0.57407993", "0.5645988", "0.56094193", "0.55473876", "0.53495145", "0.521684", "0.51685303", "0.51498526", "0.5132291", "0.5014182", "0.49951622", "0.49933416", "0.4948473", "0.4948473", "0.48978388", "0.4867619", "0.48654392", "0.48593077", "0.48541546", "0.48...
0.57814914
1
Converts list of prefixed strings to GeneralName list.
def load_gnames(self, gname_list): gnames = [] for alt in gname_list: if ':' not in alt: raise InvalidCertificate("Invalid gname: %s" % (alt,)) t, val = alt.split(':', 1) t = t.lower().strip() val = val.strip() if t == 'dn': gn = x509.DirectoryName(self.load_name(parse_dn(val))) elif t == 'dns': gn = x509.DNSName(val) elif t == 'email': gn = x509.RFC822Name(val) elif t == 'uri': gn = x509.UniformResourceIdentifier(val) elif t == 'ip': if val.find(':') >= 0: gn = x509.IPAddress(ipaddress.IPv6Address(val)) else: gn = x509.IPAddress(ipaddress.IPv4Address(val)) elif t == 'dn': gn = x509.DirectoryName(self.load_name(parse_dn(val))) elif t == 'net': if val.find(':') >= 0: gn = x509.IPAddress(ipaddress.IPv6Network(val)) else: gn = x509.IPAddress(ipaddress.IPv4Network(val)) else: raise Exception('Invalid GeneralName: ' + alt) gnames.append(gn) return gnames
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_to_names(names):\n names_list = []\n for n in names:\n names_list.append(names[n].details['name'])\n return names_list", "def original_names(names):\n if len(names) > 0 and isinstance(names[0], (list, tuple)):\n names = [x[0] for x in names]\n\n return [re.sub('_+$', '', x) ...
[ "0.65021443", "0.6432721", "0.61846787", "0.6088756", "0.6081885", "0.6031575", "0.6005844", "0.59734565", "0.5912184", "0.58610666", "0.5832652", "0.5829637", "0.58152074", "0.574755", "0.5740378", "0.5698568", "0.5694689", "0.56923187", "0.5686958", "0.56855613", "0.56847",...
0.6499037
1
Return SubjectAltNames as GeneralNames
def get_san_gnames(self): return self.load_gnames(self.san)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_subject_alt(self, name):\n\n if self._subject_alt_name is None:\n return []\n\n output = []\n for general_name in self._subject_alt_name:\n if general_name.name == name:\n output.append(general_name.native)\n return output", "def subject_a...
[ "0.7809142", "0.72061706", "0.70564437", "0.6959005", "0.6878344", "0.6363056", "0.61469597", "0.5626064", "0.5579359", "0.5547272", "0.548135", "0.5419874", "0.53881466", "0.53838485", "0.5289228", "0.5285456", "0.5278819", "0.5261047", "0.5261047", "0.52362436", "0.5235821"...
0.0
-1
Return ocsp_urls as GeneralNames
def get_ocsp_gnames(self): urls = ['uri:' + u for u in self.ocsp_urls] return self.load_gnames(urls)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_issuer_urls_gnames(self):\n urls = ['uri:' + u for u in self.issuer_urls]\n return self.load_gnames(urls)", "def urls(self) -> list[str]:\r\n ...", "def getURLs():", "def list_urls(self, prefix: str = \"\", etl_name: str = None) -> Iterable[str]:", "def get_crl_gnames(self):\n ...
[ "0.6319815", "0.6266063", "0.6263989", "0.62039906", "0.60305554", "0.5934846", "0.5844959", "0.583849", "0.58368385", "0.56617916", "0.5622121", "0.5613717", "0.55928856", "0.5585941", "0.55812305", "0.5537399", "0.5493335", "0.5492435", "0.5488834", "0.54792345", "0.5478065...
0.72922915
0
Return issuer_urls as GeneralNames
def get_issuer_urls_gnames(self): urls = ['uri:' + u for u in self.issuer_urls] return self.load_gnames(urls)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subject_alt_uris(self):\n\n return self._get_subject_alt('uniform_resource_identifier')", "def subject_alt_domains(self):\n\n return self._get_subject_alt('dns_name')", "def get_crl_gnames(self):\n urls = ['uri:' + u for u in self.crl_urls]\n return self.load_gnames(urls)", "d...
[ "0.61785847", "0.59527624", "0.5829397", "0.5827037", "0.5789031", "0.57227594", "0.5698465", "0.5667429", "0.56406856", "0.55386025", "0.5526594", "0.55237424", "0.54851675", "0.5471927", "0.54601336", "0.54285586", "0.5422123", "0.5397905", "0.53853244", "0.53811383", "0.53...
0.83089095
0
Return crl_urls as GeneralNames
def get_crl_gnames(self): urls = ['uri:' + u for u in self.crl_urls] return self.load_gnames(urls)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_issuer_urls_gnames(self):\n urls = ['uri:' + u for u in self.issuer_urls]\n return self.load_gnames(urls)", "def urls(self) -> list[str]:\r\n ...", "def list_urls(self, prefix: str = \"\", etl_name: str = None) -> Iterable[str]:", "def getURLs():", "def AuthorURLs(entry):\n ...
[ "0.6717781", "0.6483335", "0.6474641", "0.637163", "0.6109357", "0.59807044", "0.5915114", "0.5866936", "0.57854867", "0.575787", "0.57498235", "0.57257307", "0.56991327", "0.5698962", "0.5662451", "0.5650308", "0.55682266", "0.5550901", "0.55472463", "0.5547159", "0.55458784...
0.69459665
0
Return TLS Feature list
def get_tls_features(self): tls_features = [] if self.ocsp_must_staple: tls_features.append(x509.TLSFeatureType.status_request) if self.ocsp_must_staple_v2: tls_features.append(x509.TLSFeatureType.status_request_v2) return tls_features
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _runtime_feature_list(self):\n supported_features_command = [self._path_to_driver(), '--print-supported-features']\n try:\n output = self._executive.run_command(supported_features_command, error_handler=Executive.ignore_error)\n except OSError, e:\n _log.warn(\"Except...
[ "0.6554773", "0.6229621", "0.6155694", "0.6152324", "0.6034768", "0.59933424", "0.5971594", "0.5917329", "0.5915376", "0.5915376", "0.5915376", "0.5915376", "0.5885361", "0.5870308", "0.58026606", "0.57677984", "0.5735279", "0.5718903", "0.57177716", "0.5692858", "0.56664056"...
0.77832854
0
Add common extensions to Cert or CSR builder.
def install_extensions(self, builder): # BasicConstraints, critical if self.ca: ext = x509.BasicConstraints(ca=True, path_length=self.path_length) else: ext = x509.BasicConstraints(ca=False, path_length=None) builder = builder.add_extension(ext, critical=True) # KeyUsage, critical ku_args = {k: k in self.usage for k in KU_FIELDS} if self.ca: ku_args.update(CA_DEFAULTS) elif not self.usage: ku_args.update(NONCA_DEFAULTS) for k in XKU_DEFAULTS: if k in self.usage: for k2 in XKU_DEFAULTS[k]: ku_args[k2] = True ext = make_key_usage(**ku_args) builder = builder.add_extension(ext, critical=True) # ExtendedKeyUsage, critical xku = [x for x in self.usage if x not in KU_FIELDS] xku_bad = [x for x in xku if x not in XKU_CODE_TO_OID] if xku_bad: raise InvalidCertificate("Unknown usage keywords: %s" % (','.join(xku_bad),)) if xku: xku_oids = [XKU_CODE_TO_OID[x] for x in xku] ext = x509.ExtendedKeyUsage(xku_oids) builder = builder.add_extension(ext, critical=True) # NameConstraints, critical if (self.exclude_subtrees or self.permit_subtrees) and self.ca: allow = self.load_gnames(self.permit_subtrees) or None disallow = self.load_gnames(self.exclude_subtrees) or None ext = x509.NameConstraints(allow, disallow) builder = builder.add_extension(ext, critical=True) # SubjectAlternativeName if self.san: ext = x509.SubjectAlternativeName(self.get_san_gnames()) builder = builder.add_extension(ext, critical=False) # CRLDistributionPoints if self.crl_urls: full_names = self.get_crl_gnames() reasons = None crl_issuer = None point = x509.DistributionPoint(full_names, None, reasons, crl_issuer) ext = x509.CRLDistributionPoints([point]) builder = builder.add_extension(ext, critical=False) # AuthorityInformationAccess if self.ocsp_urls or self.issuer_urls: oid = AuthorityInformationAccessOID.OCSP ocsp_list = [x509.AccessDescription(oid, gn) for gn in self.get_ocsp_gnames()] oid = AuthorityInformationAccessOID.CA_ISSUERS ca_list = [x509.AccessDescription(oid, gn) for gn in self.get_issuer_urls_gnames()] ext = x509.AuthorityInformationAccess(ocsp_list + ca_list) builder = builder.add_extension(ext, critical=False) # OCSPNoCheck if self.ocsp_nocheck: ext = x509.OCSPNoCheck() builder = builder.add_extension(ext, critical=False) # TLSFeature: status_request, status_request_v2 tls_features = self.get_tls_features() if tls_features: ext = x509.TLSFeature(tls_features) builder = builder.add_extension(ext, critical=False) # configured builder return builder
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_extensions(self, ext_stack):\n return m2.x509_req_add_extensions(self.req, ext_stack._ptr())", "def build_extension(self, ext):\n build_all()\n super(cffiBuilder, self).build_extension(ext)", "def build_extensions(self):\n c = self.compiler.compiler_type\n CF = [] ; L...
[ "0.68608624", "0.6400358", "0.63571113", "0.63295335", "0.63138413", "0.6188864", "0.6090052", "0.6024872", "0.59441936", "0.5844638", "0.5754354", "0.5681884", "0.56702286", "0.5670175", "0.56068116", "0.5569463", "0.5534916", "0.5526108", "0.54374963", "0.54269266", "0.5408...
0.7651184
0
Print out list field.
def show_list(self, desc, lst, writeln): if not lst: return val = ', '.join([list_escape(v) for v in lst]) writeln("%s: %s" % (desc, val))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_list(self):\r\n pass", "def print_list(self):\n self.print_avec_separateur(\" \")", "def list_print(self):\n node = self.cur_node # cant point to ll!\n while node:\n print(node.data)\n node = node.next", "def scapy_fields_FieldListField_i2repr(s...
[ "0.7778303", "0.72787195", "0.68855184", "0.6764633", "0.6687931", "0.6623039", "0.65351075", "0.65242046", "0.65014845", "0.64988315", "0.6490655", "0.6490049", "0.6484101", "0.6460331", "0.64499795", "0.6441054", "0.64375824", "0.64356184", "0.64225334", "0.63925815", "0.63...
0.6982858
2
Returns backend to use.
def get_backend(): from cryptography.hazmat.backends import default_backend return default_backend()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_backend():\n return _BACKEND", "def get_backend(name):\n return _DEFAULT_PROVIDER.get_backend(name)", "def get_backend():\n return __SETTINGS__._BACKEND", "def _get_backend(args):\n if args.backend == 'gatttool':\n backend = GatttoolBackend\n elif args.backend == 'bluepy':\n backend = ...
[ "0.8743596", "0.8575249", "0.83286643", "0.8244357", "0.82377666", "0.8199863", "0.8199863", "0.816488", "0.8118611", "0.8118611", "0.80922145", "0.80846", "0.7978867", "0.7977651", "0.7964498", "0.7956947", "0.7936695", "0.7910934", "0.7906332", "0.7804737", "0.7777473", "...
0.7869946
19
Default arguments for KeyUsage.
def make_key_usage(digital_signature=False, content_commitment=False, key_encipherment=False, data_encipherment=False, key_agreement=False, key_cert_sign=False, crl_sign=False, encipher_only=False, decipher_only=False): return x509.KeyUsage(digital_signature=digital_signature, content_commitment=content_commitment, key_encipherment=key_encipherment, data_encipherment=data_encipherment, key_agreement=key_agreement, key_cert_sign=key_cert_sign, crl_sign=crl_sign, encipher_only=encipher_only, decipher_only=decipher_only)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_extra_args(self):\n super(AwsAccessListKeysMethod, self).add_extra_args()\n self.parser.add_argument(\"--key_pair_name\", required=False, default=None,\n help=\"AWS Key Pair name\")", "def add_key_arguments(parser):\n group = parser.add_argument_group(\"Ke...
[ "0.63416225", "0.63310456", "0.61922413", "0.6166601", "0.60149294", "0.5977559", "0.5891303", "0.5785784", "0.57817113", "0.5779327", "0.5699099", "0.5675902", "0.56591386", "0.56465507", "0.56432736", "0.5643039", "0.5611888", "0.55910945", "0.5587594", "0.558592", "0.55859...
0.516289
93
Main CSR creation code.
def create_x509_req(privkey, subject_info): builder = x509.CertificateSigningRequestBuilder() builder = builder.subject_name(subject_info.get_name()) builder = subject_info.install_extensions(builder) # create final request req = builder.sign(private_key=privkey, algorithm=SHA256(), backend=get_backend()) return req
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _generate_csr_and_key():\n key = rsa.generate_private_key(\n public_exponent=65537,\n key_size=2048,\n backend=default_backend())\n\n csr = x509.CertificateSigningRequestBuilder().subject_name(x509.Name([\n x509.NameAttribute(NameOID.COMMON_NAME, u\"Magnum User\"),\n ])).si...
[ "0.6959776", "0.68491095", "0.6717614", "0.6480697", "0.646453", "0.6371925", "0.6347647", "0.6325621", "0.6219762", "0.6209572", "0.61821324", "0.6039916", "0.58269167", "0.58240783", "0.5717246", "0.56873", "0.5679572", "0.5627929", "0.5522485", "0.5479461", "0.5473484", ...
0.54836375
19
Main cert creation code.
def create_x509_cert(privkey, pubkey, subject_info, issuer_info, days): if not isinstance(subject_info, CertInfo): info = CertInfo() info.load_from_existing(subject_info) subject_info = info if not isinstance(issuer_info, CertInfo): info = CertInfo() info.load_from_existing(issuer_info) issuer_info = info dt_now = datetime.utcnow() dt_start = dt_now - timedelta(hours=1) dt_end = dt_now + timedelta(days=days) builder = (x509.CertificateBuilder() .subject_name(subject_info.get_name()) .issuer_name(issuer_info.get_name()) .not_valid_before(dt_start) .not_valid_after(dt_end) .serial_number(int(uuid.uuid4())) .public_key(pubkey)) builder = subject_info.install_extensions(builder) # SubjectKeyIdentifier ext = x509.SubjectKeyIdentifier.from_public_key(pubkey) builder = builder.add_extension(ext, critical=False) # AuthorityKeyIdentifier ext = x509.AuthorityKeyIdentifier.from_issuer_public_key(privkey.public_key()) builder = builder.add_extension(ext, critical=False) # IssuerAlternativeName if issuer_info.san: ext = x509.IssuerAlternativeName(issuer_info.get_san_gnames()) builder = builder.add_extension(ext, critical=False) # final cert cert = builder.sign(private_key=privkey, algorithm=SHA256(), backend=get_backend()) return cert
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new_cert(self, commonname, extensions=None):\n\n serial = self._get_serial()\n pkey = self._create_pkey(commonname, serial)\n self._create_cert(pkey, commonname, serial, extensions)", "def _init_keys(self):\n\n basic_constraints = crypto.X509Extension('basicConstraints'.encode('as...
[ "0.70912915", "0.69870734", "0.6928703", "0.69179356", "0.6904272", "0.68842286", "0.6849011", "0.6816732", "0.67960584", "0.6723379", "0.6536452", "0.65353703", "0.6409508", "0.6319466", "0.6305267", "0.6305267", "0.6248997", "0.6193512", "0.61818844", "0.6146365", "0.610321...
0.6169744
19
New Elliptic Curve key
def new_ec_key(name='secp256r1'): if name not in EC_CURVES: raise ValueError('Unknown curve') return ec.generate_private_key(curve=EC_CURVES[name], backend=get_backend())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_ecc_private_key(curve_name: str = 'P-256') -> EllipticCurvePrivateKeyWithSerialization:\n curve_obj = {\n 'P-256': ec.SECP256R1(),\n 'P-384': ec.SECP384R1(),\n 'P-521': ec.SECP521R1()\n }[curve_name]\n return ec.generate_private_key(curve_obj, default_backend()) # type: ...
[ "0.7240443", "0.702215", "0.69358593", "0.69095886", "0.6824323", "0.644343", "0.6409015", "0.63836247", "0.6371176", "0.63416773", "0.6324077", "0.62912446", "0.6263568", "0.62155515", "0.6212738", "0.6199788", "0.6176039", "0.6160097", "0.6147054", "0.6129228", "0.61161697"...
0.78493464
0
Serialize key in PEM format, optionally encrypted.
def key_to_pem(key, password=None): if password: enc = BestAvailableEncryption(as_bytes(password)) else: enc = NoEncryption() return key.private_bytes(Encoding.PEM, PrivateFormat.PKCS8, enc)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def encode_key(self, key):\n return key.private_bytes(\n encoding=serialization.Encoding.PEM,\n format=serialization.PrivateFormat.TraditionalOpenSSL,\n encryption_algorithm=serialization.NoEncryption(),\n ).decode(encoding='UTF-8')", "def serialize_key(key: str) ->...
[ "0.7412692", "0.68068147", "0.6512063", "0.64399076", "0.6427828", "0.6327557", "0.6320969", "0.6244174", "0.6185736", "0.61740416", "0.61382186", "0.61248946", "0.6111784", "0.6021915", "0.60145104", "0.5913322", "0.58946526", "0.5891813", "0.5877754", "0.58637", "0.58601266...
0.6648909
2
Serialize certificate in PEM format.
def cert_to_pem(cert): return cert.public_bytes(Encoding.PEM)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def encode_certificate(self, cert):\n return cert.public_bytes(\n serialization.Encoding.PEM,\n ).decode(encoding='UTF-8')", "def pem_armor_certificate(certificate):\n\n return asymmetric.dump_certificate(certificate)", "def serialize_certificate(\n certificate: Certificate, enco...
[ "0.7233042", "0.68470275", "0.68383855", "0.6716175", "0.6495609", "0.6100652", "0.60305905", "0.60305905", "0.60305905", "0.60291034", "0.6010482", "0.59719867", "0.59408164", "0.59336966", "0.59336966", "0.5918769", "0.59016013", "0.5878901", "0.58332604", "0.5830136", "0.5...
0.7239738
0
Serialize certificate request in PEM format.
def req_to_pem(req): return req.public_bytes(Encoding.PEM)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cert_to_pem(cert):\n return cert.public_bytes(Encoding.PEM)", "def _build_pem(tls_cert):\n pem = ()\n if tls_cert.intermediates:\n for c in tls_cert.intermediates:\n pem = pem + (c,)\n if tls_cert.certificate:\n pem = pem + (tls_cert.certificate,)\n if tls_cert.private...
[ "0.6295511", "0.6238403", "0.6178628", "0.6023338", "0.596094", "0.5930526", "0.5825464", "0.5816554", "0.57833594", "0.57833594", "0.5726823", "0.571607", "0.56658447", "0.5638736", "0.56148493", "0.55883175", "0.5558911", "0.54970115", "0.54970115", "0.54914117", "0.5478445...
0.7018637
0
Read private key, decrypt if needed.
def load_key(fn, psw=None): if not fn: die("Need private key") if psw: psw = as_bytes(psw) data = load_gpg_file(fn) key = load_pem_private_key(data, password=psw, backend=get_backend()) return key
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def decrypt(data, private_key):\r\n\r\n # Retrieve session key, tag, ciphertext and nonce from file\r\n enc_session_key, nonce, tag, ciphertext = \\\r\n [ file_in.read(x) for x in (private_key.size_in_bytes(), 16, 16, -1) ]\r\n\r\n\r\n # Decrypt the session key\r\n session_key = cipher_rsa.decrypt(e...
[ "0.6939709", "0.66746044", "0.66666764", "0.65895903", "0.6577401", "0.6512976", "0.6444183", "0.6393576", "0.6384379", "0.6342567", "0.631341", "0.6248368", "0.61970115", "0.6189783", "0.6187942", "0.6154129", "0.6141176", "0.61391276", "0.6136478", "0.6121558", "0.6083108",...
0.5849048
45
Read password from potentially gpgencrypted file.
def load_password(fn): if not fn: return None data = load_gpg_file(fn) data = data.strip(b'\n') return data
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_key():\n return open(\"pass.key\", \"rb\").read()", "def _PasswordFromFile(self, hostname, port, username):\n\n\t\tif username == None or len(username) == 0:\n\t\t\treturn None\n\n\t\tif hostname == None or hostname == UNIX_DOMAIN_PATH:\n\t\t\thostname = DefaultHost\n\n\t\tpgpassfile = self._getPoolP...
[ "0.6575987", "0.6558546", "0.64441496", "0.6166849", "0.60289574", "0.600363", "0.5950623", "0.59272367", "0.59127575", "0.5835766", "0.5814732", "0.57961124", "0.5790752", "0.5773013", "0.5772841", "0.5765816", "0.57390904", "0.5737546", "0.5721898", "0.56895983", "0.5678449...
0.807333
0
Parse list of strings, separated by c.
def loop_escaped(val, c): if not val: val = '' val = as_unicode(val) rc = re.compile(r'([^%s\\]|\\.)*' % re.escape(c)) pos = 0 while pos < len(val): if val[pos] == c: pos += 1 continue m = rc.match(val, pos) if not m: raise Exception('rx bug') pos = m.end() yield unescape(m.group(0))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_list(slist):\n res = []\n for v in loop_escaped(slist, ','):\n v = v.strip()\n if v:\n res.append(v)\n return res", "def parse_list(value: str) -> list[str]:\n segments = _QUOTED_SEGMENT_RE.findall(value)\n for segment in segments:\n left, match, right = v...
[ "0.6619962", "0.6402648", "0.61849755", "0.6105302", "0.6098038", "0.6075494", "0.60474575", "0.5930806", "0.59285104", "0.5884096", "0.5826036", "0.58210325", "0.58042055", "0.5785377", "0.57437575", "0.57404375", "0.5691565", "0.56817746", "0.5671865", "0.56397724", "0.5596...
0.0
-1
Parse commaseparated list to strings.
def parse_list(slist): res = [] for v in loop_escaped(slist, ','): v = v.strip() if v: res.append(v) return res
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse(self, output):\n q = '['\n prepro = [line for line in output if \"['''', ''''],\" not in line]\n prepro = [line for line in prepro if \"[',', ','],\" not in line]\n for line in prepro:\n process = line.strip()\n process = process.replace('[', '(')\n ...
[ "0.6197948", "0.6151549", "0.6102005", "0.606939", "0.60056645", "0.596137", "0.5894534", "0.58915085", "0.58653396", "0.58636934", "0.58515674", "0.5836412", "0.58261746", "0.5818068", "0.5795482", "0.5790831", "0.5783101", "0.5743863", "0.5742642", "0.5727883", "0.5720543",...
0.68961257
0
Parse opensslstyle /separated list to dict.
def parse_dn(dnstr): res = [] for part in loop_escaped(dnstr, '/'): part = part.strip() if not part: continue if '=' not in part: raise InvalidCertificate("Need k=v in Name string") k, v = part.split('=', 1) res.append((k.strip(), v.strip())) return res
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _to_dict(self, data_list):\n data_dict = dict(pair.split('=') for pair in data_list)\n return data_dict", "def parse(line):\n return dict([pair.split(':') for pair in line.split()])", "def _convertToDict(self, parsed):\r\n d = dict()\r\n itp = iter(parsed)\r\n for ...
[ "0.59891826", "0.58771014", "0.5808679", "0.58030844", "0.5633769", "0.562944", "0.5532584", "0.54721385", "0.5428147", "0.5418335", "0.54139864", "0.53684205", "0.5357799", "0.5338177", "0.5321925", "0.5310008", "0.53023285", "0.52133584", "0.520872", "0.5188802", "0.51713",...
0.4789175
71
Print message and exit.
def die(txt, *args): if args: txt = txt % args sys.stderr.write(txt + '\n') sys.exit(1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exit_message(message):\n\tprint(yellow(message))\n\tsys.exit(1)", "def exitWithMsg(msg):\n\tprint(msg + \" -- quitting\")\n\tsys.exit(0)", "def print_ok(msg):\n print('OK - %s' % (msg))\n sys.exit(0)", "def exit(cls, msg):\n Console.error(msg)\n sys.exit()", "def print_msg_exit(msg=...
[ "0.77262276", "0.76083595", "0.74169284", "0.73643696", "0.7243128", "0.719227", "0.7183562", "0.71205103", "0.7051382", "0.70065045", "0.69638604", "0.6944771", "0.69369346", "0.69369346", "0.6917173", "0.6913734", "0.6887772", "0.68613786", "0.679101", "0.6778247", "0.67688...
0.0
-1
Print message to stderr.
def msg(txt, *args): if QUIET: return if args: txt = txt % args sys.stderr.write(txt + '\n')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def printerr(message):\n sys.stderr.write('{}\\n'.format(message))\n sys.stderr.flush()", "def print_stderr(message):\n sys.stderr.write(\"%s\\n\" % message)\n sys.stderr.flush()", "def to_stderr(message):\n print >> sys.stderr, message", "def error(message):\n print(message, file=sys.s...
[ "0.83818024", "0.83467203", "0.8323325", "0.8299432", "0.8288418", "0.8276263", "0.82736266", "0.81002593", "0.80394256", "0.79781455", "0.790646", "0.7891345", "0.7791808", "0.76625943", "0.75944436", "0.75564045", "0.7551808", "0.7516099", "0.75122887", "0.75074214", "0.747...
0.0
-1
Collect commandline arguments into CertInfo.
def info_from_args(args): return CertInfo( subject=parse_dn(args.subject), usage=parse_list(args.usage), alt_names=parse_list(args.san), ocsp_nocheck=args.ocsp_nocheck, ocsp_must_staple=args.ocsp_must_staple, ocsp_must_staple_v2=args.ocsp_must_staple_v2, ocsp_urls=parse_list(args.ocsp_urls), crl_urls=parse_list(args.crl_urls), issuer_urls=parse_list(args.issuer_urls), permit_subtrees=parse_list(args.permit_subtrees), exclude_subtrees=parse_list(args.exclude_subtrees), ca=args.CA, path_length=args.path_length)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _set_arguments(self):\n cert_location = f\"dependencies{sep}certificates{sep}localuser.crt\"\n key_location = f\"dependencies{sep}certificates{sep}localuser.key\"\n assert Path(cert_location).exists(), (\n f\"The certificate isn't \"\n f\"present at location {Path(cer...
[ "0.650702", "0.6123743", "0.60399014", "0.60012686", "0.59843737", "0.57966566", "0.5721231", "0.5682582", "0.5598154", "0.5594984", "0.5591436", "0.5585888", "0.55673426", "0.55233204", "0.5516206", "0.5511681", "0.55067706", "0.54973185", "0.54691166", "0.545013", "0.544308...
0.6634239
0
Sign with already loaded parameters.
def do_sign(subject_csr, issuer_obj, issuer_key, days, path_length, reqInfo, reset_info=None): # Certificate duration if days is None: die("Need --days") if days <= 0: die("Invalid --days") # Load CA info issuer_info = CertInfo(load=issuer_obj) # Load certificate request subject_info = CertInfo(load=subject_csr) if reset_info: subject_info = reset_info # Check CA parameters if not same_pubkey(subject_csr, issuer_obj): if not issuer_info.ca: die("Issuer must be CA.") if 'key_cert_sign' not in issuer_info.usage: die("Issuer CA is not allowed to sign certs.") if subject_info.ca: if not same_pubkey(subject_csr, issuer_obj): # not self-signing, check depth if issuer_info.path_length == 0: die("Issuer cannot sign sub-CAs") if issuer_info.path_length - 1 < path_length: die("--path-length not allowed by issuer") # Load subject's public key, check sanity pkey = subject_csr.public_key() if isinstance(pkey, ec.EllipticCurvePublicKey): pkeyinfo = 'ec:' + str(pkey.curve.name) if pkey.curve.name not in EC_CURVES: die("Curve not allowed: %s", pkey.curve.name) elif isinstance(pkey, rsa.RSAPublicKey): pkeyinfo = 'rsa:' + str(pkey.key_size) if pkey.key_size < MIN_RSA_BITS or pkey.key_size > MAX_RSA_BITS: die("RSA size not allowed: %s", pkey.key_size) else: die("Unsupported public key: %s", str(pkey)) # Report if subject_info.ca: msg('Signing CA cert [%s] - %s', pkeyinfo, reqInfo) else: msg('Signing end-entity cert [%s] - %s', pkeyinfo, reqInfo) msg('Issuer name: %s', render_name(issuer_info.subject)) msg('Subject:') subject_info.show(msg_show) # Load CA private key if not same_pubkey(issuer_key, issuer_obj): die("--ca-private-key does not match --ca-info data") # Stamp request cert = create_x509_cert(issuer_key, subject_csr.public_key(), subject_info, issuer_info, days=days) return cert
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sign(self, payload):\n raise NotImplementedError", "def signSign(self):\r\n if \"signature\" in self: # or \"signatures\" in self ?\r\n self.pop(\"id\", False)\r\n try:\r\n self[\"signSignature\"] = dposlib.core.crypto.getSignature(\r\n s...
[ "0.67569077", "0.6738855", "0.6735283", "0.6622873", "0.6465191", "0.64287317", "0.6230365", "0.6186728", "0.6170761", "0.61308557", "0.6089753", "0.6075846", "0.605452", "0.60319453", "0.6018945", "0.6009839", "0.5959301", "0.5959301", "0.5891443", "0.587198", "0.5857418", ...
0.0
-1
Load commandline arguments, create Certificate Signing Request (CSR).
def req_command(args): if args.files: die("Unexpected positional arguments") subject_info = info_from_args(args) if subject_info.ca: msg('Request for CA cert') else: msg('Request for end-entity cert') subject_info.show(msg_show) # Load private key, create signing request key = load_key(args.key, load_password(args.password_file)) req = create_x509_req(key, subject_info) do_output(req_to_pem(req), args, 'req')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sign_command(args):\n if args.files:\n die(\"Unexpected positional arguments\")\n\n # Load certificate request\n if not args.request:\n die(\"Need --request\")\n subject_csr = load_req(args.request)\n\n reset_info = None\n if args.reset:\n reset_info = info_from_args(args...
[ "0.7071083", "0.6448927", "0.64444983", "0.63485956", "0.6237446", "0.6178711", "0.61732894", "0.6083192", "0.6013771", "0.59875655", "0.5984441", "0.5983292", "0.5934362", "0.5875236", "0.58677095", "0.58173174", "0.58064055", "0.5790398", "0.5781913", "0.5750335", "0.574030...
0.6887356
1
Load commandline arguments, output cert.
def sign_command(args): if args.files: die("Unexpected positional arguments") # Load certificate request if not args.request: die("Need --request") subject_csr = load_req(args.request) reset_info = None if args.reset: reset_info = info_from_args(args) # Load CA info if not args.ca_info: die("Need --ca-info") if args.ca_info.endswith('.csr'): issuer_obj = load_req(args.ca_info) else: issuer_obj = load_cert(args.ca_info) # Load CA private key issuer_key = load_key(args.ca_key, load_password(args.password_file)) if not same_pubkey(issuer_key, issuer_obj): die("--ca-private-key does not match --ca-info data") # Certificate generation cert = do_sign(subject_csr, issuer_obj, issuer_key, args.days, args.path_length, args.request, reset_info=reset_info) # Write certificate do_output(cert_to_pem(cert), args, 'x509')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main(cli_args):\n store_obj = cert_human_py3.CertChainStore.from_socket(\n host=cli_args.host, port=cli_args.port\n )\n\n print(store_obj.dump_json)", "def main():\n ssl_date_fmt = r'%b %d %H:%M:%S %Y %Z'\n #cert_file_name = os.path.join(os.path.dirname(__file__), \"testcert.pem\")\n\n ...
[ "0.65129656", "0.6317035", "0.62203246", "0.6165697", "0.614384", "0.58114463", "0.5741986", "0.57261765", "0.57255286", "0.5722998", "0.5697117", "0.56766486", "0.5666311", "0.56107074", "0.5607905", "0.5587706", "0.55837715", "0.55678767", "0.54588795", "0.5440277", "0.5425...
0.5525959
18
Load commandline arguments, create selfsigned CRT.
def selfsign_command(args): if args.files: die("Unexpected positional arguments") subject_info = info_from_args(args) if subject_info.ca: msg('Request for CA cert') else: msg('Request for end-entity cert') subject_info.show(msg_show) # Load private key, create signing request key = load_key(args.key, load_password(args.password_file)) subject_csr = create_x509_req(key, subject_info) # sign created request cert = do_sign(subject_csr, subject_csr, key, args.days, args.path_length, '<selfsign>') do_output(cert_to_pem(cert), args, 'x509')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(self, line):\r\n if os.name == 'nt':\r\n if not ctypes.windll.shell32.IsUserAnAdmin() != 0:\r\n self.app.typepath.adminpriv = False\r\n elif not os.getuid() == 0:\r\n self.app.typepath.adminpriv = False\r\n\r\n nargv = []\r\n curr = []\r\n ...
[ "0.60164946", "0.5917256", "0.5911841", "0.5911841", "0.5905188", "0.5905188", "0.58483124", "0.58254886", "0.570544", "0.5692321", "0.5691585", "0.56263906", "0.5617899", "0.5611776", "0.56115735", "0.55883586", "0.55690145", "0.55671674", "0.5558053", "0.54855394", "0.54752...
0.0
-1
Dump .crt and .csr files.
def show_command(args): for fn in args.files: ext = os.path.splitext(fn)[1].lower() if ext == '.csr': cmd = ['openssl', 'req', '-in', fn, '-text'] elif ext == '.crt': cmd = ['openssl', 'x509', '-in', fn, '-text'] else: die("Unsupported file: %s", fn) subprocess.check_call(cmd)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dump_to_disk(self, prefix):\n\n f = open(prefix + rpki.sundial.now().isoformat() + \"Z.cms\", \"wb\")\n f.write(self.get_DER())\n f.close()", "def dump_vecs():\n v_file = os.path.join(TMP_DIR, 'vectorizer.pickle')\n d_file = os.path.join(TMP_DIR, 'dectorizer.pickle')\n f_file = os.pat...
[ "0.5700215", "0.5441109", "0.53787977", "0.5377256", "0.53298485", "0.53045154", "0.5229976", "0.522061", "0.5135358", "0.5086592", "0.5069545", "0.50393033", "0.5038316", "0.5030887", "0.50227106", "0.50061053", "0.49667236", "0.49623433", "0.4961675", "0.49565977", "0.49195...
0.0
-1
Load arguments, select and run command.
def run_sysca(argv): global QUIET ap = setup_args() args = ap.parse_args(argv) if args.quiet: QUIET = True if args.command == 'new-key': newkey_command(args) elif args.command == 'request': req_command(args) elif args.command == 'sign': sign_command(args) elif args.command == 'selfsign': selfsign_command(args) elif args.command == 'show': show_command(args) else: die("Unknown command: %s", args.command)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main():\n sys.argv.pop(0)\n (cmd, var, args) = process_options(sys.argv[:])\n execute(cmd, var, args)", "def main(args):\n options = parse_cmd_parameters_(args)\n execute_(options)", "def do_command(self, args):\n pass", "def execute(self):\n \n current_dir = os.getcwd...
[ "0.6881134", "0.66955614", "0.6658523", "0.6462016", "0.64445746", "0.6421537", "0.6377791", "0.63629246", "0.6346535", "0.6292145", "0.62857026", "0.6277357", "0.62285894", "0.62285894", "0.6209417", "0.61959785", "0.61842215", "0.61753494", "0.61505806", "0.6132218", "0.613...
0.0
-1
Commandline application entry point.
def main(): try: return run_sysca(sys.argv[1:]) except InvalidCertificate as ex: die(str(ex))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main(args=None):\n app()\n return 0", "def main():\n CLI_APP.run()", "def main():\n app = App()\n app.run()", "def main(args=None):", "def main(args=None):", "def main(args):", "def main(args):", "def cli():\n config, auth, execute_now = read_command_line_arguments()\n main(confi...
[ "0.83380365", "0.81912965", "0.78934926", "0.77137196", "0.77137196", "0.766038", "0.766038", "0.75786704", "0.7566778", "0.7566778", "0.7566778", "0.7561944", "0.7548935", "0.75437146", "0.752279", "0.7502812", "0.74949706", "0.74422157", "0.74301237", "0.7409354", "0.739736...
0.0
-1
resets counters to 0
def reset(self): self.correct_count = 0 self.total_count = 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset_counter(self) -> None:", "def reset(self):\n self.counter = 0", "def reset (self):\n self.counter = 0", "def resetCounters(self):\n self.chain.zero_counters()\n counters = self.session.query(Counter).all()\n self.session.query(Counter).delete()", "def reset_coun...
[ "0.8522219", "0.8301985", "0.8270119", "0.82612026", "0.81530696", "0.7962359", "0.7749801", "0.7585864", "0.75297916", "0.74603754", "0.7459489", "0.7426602", "0.7421175", "0.7398909", "0.73889565", "0.7378627", "0.7351837", "0.7351327", "0.7349136", "0.7317789", "0.73143846...
0.75962293
7
resets counters to 0
def reset(self) -> None: self.true_positives = 0 self.all_positives = 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset_counter(self) -> None:", "def reset(self):\n self.counter = 0", "def reset (self):\n self.counter = 0", "def resetCounters(self):\n self.chain.zero_counters()\n counters = self.session.query(Counter).all()\n self.session.query(Counter).delete()", "def reset_coun...
[ "0.8522219", "0.8301985", "0.8270119", "0.82612026", "0.81530696", "0.7962359", "0.7749801", "0.75962293", "0.7585864", "0.75297916", "0.74603754", "0.7459489", "0.7426602", "0.7421175", "0.7398909", "0.73889565", "0.7378627", "0.7351837", "0.7351327", "0.7349136", "0.7317789...
0.71736586
33
resets counters to 0
def reset(self) -> None: self.true_positives = 0 self.actual_positives = 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset_counter(self) -> None:", "def reset(self):\n self.counter = 0", "def reset (self):\n self.counter = 0", "def resetCounters(self):\n self.chain.zero_counters()\n counters = self.session.query(Counter).all()\n self.session.query(Counter).delete()", "def reset_coun...
[ "0.8521774", "0.8300679", "0.8268725", "0.8260296", "0.8152586", "0.7961257", "0.77489495", "0.7595029", "0.75843966", "0.7528949", "0.7459658", "0.7458322", "0.7425785", "0.74207324", "0.7398623", "0.7388024", "0.7376379", "0.73507553", "0.735041", "0.73476917", "0.7314992",...
0.69865745
47
resets precision and recall
def reset(self) -> None: self.precision.reset() self.recall.reset()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _set_precision(self, precision) :\n self.__precision = self.parent().action().filter(precision)", "def change_precision(self, precision):\n if precision <= 0:\n print(\"Precision must be positive\")\n else:\n self.precision = precision\n self.input_equati...
[ "0.6554539", "0.6496719", "0.64400053", "0.63610476", "0.6251985", "0.6230156", "0.61648434", "0.61604416", "0.6144796", "0.6111396", "0.6090455", "0.6075918", "0.60632086", "0.6062955", "0.60555625", "0.6028188", "0.6028188", "0.59946746", "0.5988276", "0.5975022", "0.597060...
0.81031436
0
resets counters to 0
def reset(self) -> None: self.f1.reset()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset_counter(self) -> None:", "def reset(self):\n self.counter = 0", "def reset (self):\n self.counter = 0", "def resetCounters(self):\n self.chain.zero_counters()\n counters = self.session.query(Counter).all()\n self.session.query(Counter).delete()", "def reset_coun...
[ "0.8522219", "0.8301985", "0.8270119", "0.82612026", "0.81530696", "0.7962359", "0.7749801", "0.75962293", "0.7585864", "0.75297916", "0.74603754", "0.7459489", "0.7426602", "0.7421175", "0.7398909", "0.73889565", "0.7378627", "0.7351837", "0.7351327", "0.7349136", "0.7317789...
0.0
-1
Checks whether the array lies within the bounds Parameter
def __call__(self, value: np.ndarray) -> bool: for k, bound in enumerate(self.bounds): if bound is not None: if np.any((value > bound) if k else (value < bound)): return False return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _in_bounds(self, x, y):\r\n return 0 <= x < 8 and 0 <= y < 8", "def in_bounds(self, x, y):\n return x >= 0 and x < 8 and y >= 0 and y < 8", "def check_bounds(self, index):\n if index < self.lower_bound or index > self.upper_bound:\n return False\n return True", "def...
[ "0.7919413", "0.771798", "0.7610702", "0.7590389", "0.73956734", "0.7327171", "0.72736615", "0.7215787", "0.72097933", "0.71924824", "0.7150888", "0.71367943", "0.7099973", "0.70440334", "0.6929075", "0.6919802", "0.6912774", "0.6908318", "0.6906175", "0.6897664", "0.68784577...
0.74738806
4
Value for the standard deviation used to mutate the parameter
def sigma(self) -> tp.Union["Array", "Scalar"]: return self.parameters["sigma"] # type: ignore
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def standard_deviation(self):\r\n\t\treturn self.variance()**(1/2)", "def _std(self, data):\n var = stats.var(data)\n if var>0.0:\n sd = math.sqrt(var)\n else:\n sd = 0.0\n return sd", "def standard_dev(self):\n return self.variance()**0.5", "def calcu...
[ "0.8100612", "0.7911003", "0.7877927", "0.77923644", "0.7742439", "0.76735985", "0.7616291", "0.75770307", "0.753299", "0.74418736", "0.74262315", "0.74040097", "0.74040097", "0.740057", "0.7374691", "0.73520476", "0.7338328", "0.73318505", "0.733133", "0.733133", "0.73204684...
0.0
-1
Bounds all real values into [lower, upper] using a provided method
def set_bounds( self: A, lower: BoundValue = None, upper: BoundValue = None, method: str = "clipping", full_range_sampling: bool = False, a_min: BoundValue = None, a_max: BoundValue = None, ) -> A: # TODO improve description of methods lower, upper = _a_min_max_deprecation(**locals()) bounds = tuple(a if isinstance(a, np.ndarray) or a is None else np.array([a], dtype=float) for a in (lower, upper)) both_bounds = all(b is not None for b in bounds) # preliminary checks if self.bound_transform is not None: raise RuntimeError("A bounding method has already been set") if full_range_sampling and not both_bounds: raise ValueError("Cannot use full range sampling if both bounds are not set") checker = BoundChecker(*bounds) if not checker(self.value): raise ValueError("Current value is not within bounds, please update it first") if not (lower is None or upper is None): if (bounds[0] >= bounds[1]).any(): # type: ignore raise ValueError(f"Lower bounds {lower} should be strictly smaller than upper bounds {upper}") # update instance transforms = dict(clipping=trans.Clipping, arctan=trans.ArctanBound, tanh=trans.TanhBound) if method in transforms: if self.exponent is not None and method != "clipping": raise ValueError(f'Cannot use method "{method}" in logarithmic mode') self.bound_transform = transforms[method](*bounds) elif method == "constraint": self.register_cheap_constraint(checker) else: raise ValueError(f"Unknown method {method}") self.bounds = bounds # type: ignore self.full_range_sampling = full_range_sampling # warn if sigma is too large for range if both_bounds and method != "tanh": # tanh goes to infinity anyway std_bounds = tuple(self._to_reduced_space(b) for b in self.bounds) # type: ignore min_dist = np.min(np.abs(std_bounds[0] - std_bounds[1]).ravel()) if min_dist < 3.0: warnings.warn(f"Bounds are {min_dist} sigma away from each other at the closest, " "you should aim for at least 3 for better quality.") return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def simplebounds(cls, val, lower, upper):\n if val < lower:\n val = lower\n if val > upper:\n val = upper\n return val", "def _bound(x, min_value, max_value):\n return np.maximum(min_value, np.minimum(x, max_value))", "def apply_bound(x, var_min, var_max):\n ...
[ "0.71283054", "0.68890387", "0.65130097", "0.6450955", "0.6424436", "0.63653696", "0.63593006", "0.6322421", "0.62083405", "0.62054557", "0.6173497", "0.60966706", "0.60829145", "0.607084", "0.607084", "0.6065957", "0.59931934", "0.59931576", "0.5980716", "0.5976944", "0.5952...
0.71421045
0
Output will be cast to integer(s) through deterministic rounding.
def set_mutation(self: A, sigma: tp.Optional[tp.Union[float, "Array"]] = None, exponent: tp.Optional[float] = None) -> A: if sigma is not None: # just replace if an actual Parameter is provided as sigma, else update value (parametrized or not) if isinstance(sigma, core.Parameter) or isinstance(self.parameters._content["sigma"], core.Constant): self.parameters._content["sigma"] = core.as_parameter(sigma) else: self.sigma.value = sigma # type: ignore if exponent is not None: if self.bound_transform is not None and not isinstance(self.bound_transform, trans.Clipping): raise RuntimeError(f"Cannot set logarithmic transform with bounding transform {self.bound_transform}, " "only clipping and constraint bounding methods can accept itp.") if exponent <= 1.0: raise ValueError("Only exponents strictly higher than 1.0 are allowed") if np.min(self._value.ravel()) <= 0: raise RuntimeError("Cannot convert to logarithmic mode with current non-positive value, please update it firstp.") self.exponent = exponent return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def intify(x):\n return int(x) if almost_equal(x, round(x)) else x", "def ir(some_value):\r\n return int(round(some_value))", "def rint(a: Number) -> int:\n return np.round(a).astype(int)", "def _float2int(x: float) -> int:\n return round(x * 100)", "def __int__(self) -> int:\n\n return ...
[ "0.6755552", "0.671412", "0.66324544", "0.65836495", "0.64938366", "0.64298236", "0.63975763", "0.62805474", "0.619245", "0.616559", "0.6150345", "0.6150345", "0.61298555", "0.6088794", "0.6077856", "0.6072032", "0.6043717", "0.6036559", "0.5983136", "0.5977387", "0.59487563"...
0.0
-1
Output will be cast to integer(s) through deterministic rounding. Returns self
def set_integer_casting(self: A) -> A: self.integer = True return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __int__(self) -> int:\n\n return int(self.__float__())", "def itemsToInt(self):\n returnvalue = Matrix()\n for row in self._value:\n newRow = list()\n for item in row:\n # round the item to 3 decimal places before converting,\n # so flo...
[ "0.70756865", "0.6518239", "0.65143543", "0.64591146", "0.62661624", "0.62452054", "0.6234085", "0.6169121", "0.6146257", "0.6132525", "0.60545045", "0.6035522", "0.6035522", "0.6019279", "0.59916437", "0.59584105", "0.5947643", "0.5937057", "0.59202385", "0.5870171", "0.5870...
0.59119105
19
Converts array with appropriate shapes to reduced (uncentered) space by applying log scaling and sigma scaling
def _to_reduced_space(self, value: np.ndarray) -> np.ndarray: sigma = self.sigma.value if self.bound_transform is not None: value = self.bound_transform.backward(value) distribval = value if self.exponent is None else np.log(value) / np.log(self.exponent) reduced = distribval / sigma return reduced.ravel() # type: ignore
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rescale_data(self):\n\n # Dividing every array of simulated data vectors by the mean of that array.\n '''# Didnt work\n for key in self.data.keys():\n self.data[key] /= np.mean(self.data[key])\n '''\n\n self.rescaled = True\n\n # Mean normalization\n ...
[ "0.6439206", "0.6292463", "0.6131833", "0.60969806", "0.60392785", "0.5985598", "0.59760886", "0.59423095", "0.58070093", "0.58033174", "0.5675887", "0.5661247", "0.5655357", "0.5631111", "0.5602358", "0.5597288", "0.5594214", "0.55887544", "0.5582954", "0.55819786", "0.55760...
0.6378868
1
This method is used to set deposit return and deposit received boolean field accordingly to current Tenancy.
def _compute_payment_type(self): res = super(AccountAnalyticAccount, self)._compute_payment_type() if self._context.get('is_landlord_rent'): for tennancy in self: for payment in self.env['account.payment'].search( [('tenancy_id', '=', tennancy.id), ('state', '=', 'posted')]): if payment.payment_type == 'outbound': tennancy.deposit_received = True if payment.payment_type == 'inbound': tennancy.deposit_return = True return res
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def landlord_button_deposite_received(self):\n payment_id = False\n acc_pay_form = self.env.ref(\n 'account.view_account_payment_form')\n account_jrnl_obj = self.env['account.journal'].search(\n [('type', '=', 'sale')], limit=1)\n payment_obj = self.env['account.pa...
[ "0.5757384", "0.5666821", "0.563632", "0.5451328", "0.5437696", "0.54078245", "0.539652", "0.53773105", "0.5311555", "0.5225933", "0.52221566", "0.5212389", "0.5212031", "0.5210332", "0.5194012", "0.5192315", "0.51765287", "0.5168921", "0.51624215", "0.5126235", "0.51125246",...
0.55960554
3
This button method is used to create rent schedule Lines.
def create_rent_schedule_landlord(self): rent_obj = self.env['tenancy.rent.schedule'] for tenancy_rec in self: amount = tenancy_rec.landlord_rent if tenancy_rec.rent_type_id.renttype == 'Weekly': d1 = tenancy_rec.date_start d2 = tenancy_rec.date interval = int(tenancy_rec.rent_type_id.name) if d2 < d1: raise Warning( _('End date must be greater than start date.')) wek_diff = (d2 - d1) wek_tot1 = (wek_diff.days) / (interval * 7) wek_tot = (wek_diff.days) % (interval * 7) if wek_diff.days == 0: wek_tot = 1 if wek_tot1 > 0: for wek_rec in range(wek_tot1): rent_obj.create( { 'start_date': d1, 'amount': amount * interval or 0.0, 'property_id': tenancy_rec.property_id and tenancy_rec.property_id.id or False, 'tenancy_id': tenancy_rec.id, 'currency_id': tenancy_rec.currency_id.id or False, 'rel_tenant_id': tenancy_rec.tenant_id.id }) d1 = d1 + relativedelta(days=(7 * interval)) if wek_tot > 0: one_day_rent = 0.0 if amount: one_day_rent = (amount) / (7 * interval) rent_obj.create({ 'start_date': d1.strftime( DEFAULT_SERVER_DATE_FORMAT), 'amount': (one_day_rent * (wek_tot)) or 0.0, 'property_id': tenancy_rec.property_id and tenancy_rec.property_id.id or False, 'tenancy_id': tenancy_rec.id, 'currency_id': tenancy_rec.currency_id.id or False, 'rel_tenant_id': tenancy_rec.tenant_id.id }) elif tenancy_rec.rent_type_id.renttype != 'Weekly': if tenancy_rec.rent_type_id.renttype == 'Monthly': interval = int(tenancy_rec.rent_type_id.name) if tenancy_rec.rent_type_id.renttype == 'Yearly': interval = int(tenancy_rec.rent_type_id.name) * 12 d1 = tenancy_rec.date_start d2 = tenancy_rec.date diff = abs((d1.year - d2.year) * 12 + (d1.month - d2.month)) tot_rec = diff / interval tot_rec2 = diff % interval if abs(d1.month - d2.month) >= 0 and d1.day < d2.day: tot_rec2 += 1 if diff == 0: tot_rec2 = 1 if tot_rec > 0: tot_rec = int(tot_rec) for rec in range(tot_rec): rent_obj.create({ 'start_date': d1.strftime( DEFAULT_SERVER_DATE_FORMAT), 'amount': amount * interval or 0.0, 'property_id': tenancy_rec.property_id and tenancy_rec.property_id.id or False, 'tenancy_id': tenancy_rec.id, 'currency_id': tenancy_rec.currency_id.id or False, 'rel_tenant_id': tenancy_rec.tenant_id.id }) d1 = d1 + relativedelta(months=interval) if tot_rec2 > 0: rent_obj.create({ 'start_date': d1.strftime(DEFAULT_SERVER_DATE_FORMAT), 'amount': amount * tot_rec2 or 0.0, 'property_id': tenancy_rec.property_id and tenancy_rec.property_id.id or False, 'tenancy_id': tenancy_rec.id, 'currency_id': tenancy_rec.currency_id.id or False, 'rel_tenant_id': tenancy_rec.tenant_id.id }) return self.write({'rent_entry_chck': True})
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_line(self, buttoninstance):\r\n #del and create again to respect the order\r\n self.ids.inlayout.remove_widget(self.add_button)\r\n self.ids.inlayout.remove_widget(self.del_button)\r\n #create the new line\r\n store = get_store()\r\n lastval = store.get('Nbtimecomp...
[ "0.6388559", "0.62406707", "0.5945554", "0.59113073", "0.58027905", "0.5781649", "0.5714266", "0.5638296", "0.5438896", "0.5420091", "0.53819907", "0.5336668", "0.53099597", "0.52825195", "0.5279254", "0.5253911", "0.52533376", "0.52415204", "0.523156", "0.5220959", "0.521123...
0.5296061
13
This Method is used to overrides orm create method, to change state and tenant of related property.
def create(self, vals): res = super(AccountAnalyticAccount, self).create(vals) if self._context.get('is_landlord_rent'): res.code = self.env['ir.sequence'].next_by_code( 'landlord.rent') if res.is_landlord_rent: res.write({'is_property': False}) if 'property_id' in vals: prop_brw = self.env['account.asset'].browse( vals['property_id']) if not prop_brw.property_owner: prop_brw.write( {'property_owner': vals.get('property_owner_id')}) return res
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def perform_create(self, serializer):\n serializer.save(using=UserConf.db)", "async def create(self, **state):\n connection = state.pop(self.connection_kwarg, None)\n obj = self.model(**state)\n await obj.save(force_insert=True, connection=connection)\n return obj", "def perf...
[ "0.58959424", "0.57716787", "0.5733233", "0.5730677", "0.5730677", "0.5730677", "0.5730677", "0.5730677", "0.5730677", "0.5730677", "0.5730677", "0.5730677", "0.5730677", "0.5730677", "0.5730677", "0.5730677", "0.5730677", "0.5730677", "0.5730677", "0.5730677", "0.5730677", ...
0.575662
2
Overrides orm unlink method,
def unlink(self): if self._context.get('is_landlord_rent'): rent_ids = [] for tenancy_rec in self: analytic_ids = self.env['account.analytic.line'].search( [('account_id', '=', tenancy_rec.id)]) if analytic_ids and analytic_ids.ids: analytic_ids.unlink() rent_ids = self.env['tenancy.rent.schedule'].search( [('tenancy_id', '=', tenancy_rec.id)]) post_rent = [x.id for x in rent_ids if x.move_check is True] if post_rent: raise Warning( _('''You cannot delete Tenancy record, if any related Rent''' '''Schedule entries are in posted.''')) else: rent_ids.unlink() return super(AccountAnalyticAccount, self).unlink()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unlink(self, link_id):", "def unlink(self):\n if not self:\n return True\n \n # for recomputing fields\n self.modified(self._fields)\n \n self._check_concurrency()\n \n ...
[ "0.75455254", "0.72018594", "0.7119035", "0.71088475", "0.700685", "0.70016056", "0.683571", "0.66466945", "0.6589308", "0.65799296", "0.65786785", "0.6519045", "0.64650804", "0.64650804", "0.64448905", "0.64448905", "0.64448905", "0.64448905", "0.64410865", "0.64339375", "0....
0.6050353
61
This button method is used to Change Tenancy state to Open.
def landlord_button_start(self): if self._context.get('is_landlord_rent'): self.write({'state': 'open', 'rent_entry_chck': False})
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def toggle(self):\n self.open = not self.open", "def switch_state():\n\tDmg.OpenWindow()", "def open_restaurant(self):\n print(\"We're Open!\")", "def open_restaurant(self):\r\n print(\"The restaurant is open now \")", "def open_restaurant(self):\n\t\tprint(\"The restaurant is now open...
[ "0.6753454", "0.67351896", "0.6623262", "0.65252876", "0.63716906", "0.6349264", "0.6349264", "0.6349264", "0.63400394", "0.63400394", "0.63400394", "0.63400394", "0.6328688", "0.6301924", "0.628958", "0.6283317", "0.6266414", "0.6244455", "0.62006384", "0.619092", "0.6183897...
0.6233518
18
This button method is used to open the related account payment form view.
def landlord_button_deposite_pay(self): payment_id = False acc_pay_form = self.env.ref( 'account.view_account_payment_form') account_jrnl_obj = self.env['account.journal'].search( [('type', '=', 'purchase')], limit=1) payment_obj = self.env['account.payment'] payment_method_id = self.env.ref( 'account.account_payment_method_manual_in') for tenancy_rec in self: if tenancy_rec.acc_pay_dep_rec_id and \ tenancy_rec.acc_pay_dep_rec_id.id: return { 'view_type': 'form', 'view_id': acc_pay_form.id, 'view_mode': 'form', 'res_model': 'account.payment', 'res_id': tenancy_rec.acc_pay_dep_rec_id.id, 'type': 'ir.actions.act_window', 'target': 'current', 'context': self._context, } if tenancy_rec.deposit == 0.00: raise Warning(_('Please Enter Deposit amount.')) if tenancy_rec.deposit < 0.00: raise Warning( _('The deposit amount must be strictly positive.')) vals = { 'partner_id': tenancy_rec.property_owner_id.parent_id.id, 'partner_type': 'supplier', 'journal_id': account_jrnl_obj.id, 'payment_type': 'outbound', 'communication': 'Deposit Received', 'tenancy_id': tenancy_rec.id, 'amount': tenancy_rec.deposit, 'property_id': tenancy_rec.property_id.id, 'payment_method_id': payment_method_id.id } payment_id = payment_obj.create(vals) return { 'view_mode': 'form', 'view_id': acc_pay_form.id, 'view_type': 'form', 'res_id': payment_id and payment_id.id, 'res_model': 'account.payment', 'type': 'ir.actions.act_window', 'nodestroy': True, 'target': 'current', 'domain': '[]', 'context': { 'close_after_process': True, } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def open_invoice(self, cr, uid, ids, context=None):\n if context is None:\n context = {}\n mod_obj = self.pool.get('ir.model.data')\n for advance_pay in self.browse(cr, uid, ids, context=context):\n form_res = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_supp...
[ "0.61552536", "0.60529786", "0.59445393", "0.5872724", "0.5840807", "0.57562137", "0.5702436", "0.56132597", "0.5595778", "0.5586985", "0.55588377", "0.55404526", "0.548458", "0.54655564", "0.5451618", "0.5413497", "0.5408232", "0.5404972", "0.5403777", "0.5348176", "0.534312...
0.52446413
28
This button method is used to open the related account payment form view.
def landlord_button_deposite_received(self): payment_id = False acc_pay_form = self.env.ref( 'account.view_account_payment_form') account_jrnl_obj = self.env['account.journal'].search( [('type', '=', 'sale')], limit=1) payment_obj = self.env['account.payment'] payment_method_id = self.env.ref( 'account.account_payment_method_manual_in') for tenancy_rec in self: if tenancy_rec.acc_pay_dep_rec_id and \ tenancy_rec.acc_pay_dep_rec_id.id: return { 'view_type': 'form', 'view_id': acc_pay_form.id, 'view_mode': 'form', 'res_model': 'account.payment', 'res_id': tenancy_rec.acc_pay_dep_rec_id.id, 'type': 'ir.actions.act_window', 'target': 'current', 'context': self._context, } if tenancy_rec.deposit == 0.00: raise Warning(_('Please Enter Deposit amount.')) if tenancy_rec.deposit < 0.00: raise Warning( _('The deposit amount must be strictly positive.')) vals = { 'partner_id': tenancy_rec.property_owner_id.parent_id.id, 'partner_type': 'customer', 'journal_id': account_jrnl_obj.id, 'payment_type': 'inbound', 'communication': 'Deposit Received', 'tenancy_id': tenancy_rec.id, 'amount': tenancy_rec.deposit, 'property_id': tenancy_rec.property_id.id, 'payment_method_id': payment_method_id.id } payment_id = payment_obj.create(vals) return { 'view_mode': 'form', 'view_id': acc_pay_form.id, 'view_type': 'form', 'res_id': payment_id and payment_id.id, 'res_model': 'account.payment', 'type': 'ir.actions.act_window', 'nodestroy': True, 'target': 'current', 'domain': '[]', 'context': { 'close_after_process': True, } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def open_invoice(self, cr, uid, ids, context=None):\n if context is None:\n context = {}\n mod_obj = self.pool.get('ir.model.data')\n for advance_pay in self.browse(cr, uid, ids, context=context):\n form_res = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_supp...
[ "0.61550695", "0.6056384", "0.59469336", "0.5873533", "0.5842952", "0.57555926", "0.57015985", "0.56164473", "0.559442", "0.5588485", "0.5559973", "0.55400896", "0.5487203", "0.5468848", "0.5451458", "0.541463", "0.5409489", "0.540566", "0.5403033", "0.534871", "0.5344379", ...
0.0
-1
This button method is used to Change Tenancy state to close.
def landlord_button_close(self): return self.write({'state': 'close'})
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def onBtnCloseClicked(self):\n self.close()", "def close_UI(self):", "def _cancel(self, __button):\r\n\r\n self.assistant.destroy()", "def _cancel(self, __button):\r\n\r\n self.assistant.destroy()", "def close(self, state):\n pass", "def close(event):\n event.widget.destroy...
[ "0.7391783", "0.68851864", "0.68595886", "0.68595886", "0.6839893", "0.68002075", "0.6791322", "0.6786216", "0.67538434", "0.67446655", "0.67278045", "0.67195815", "0.66731733", "0.6658879", "0.665314", "0.665314", "0.6634717", "0.6634717", "0.6610405", "0.66013527", "0.65797...
0.76498365
0
This button method is used to Change Tenancy state to Cancelled.
def landlord_button_cancel_tenancy(self): for record in self: self.write( {'state': 'cancelled', 'tenancy_cancelled': True}) rent_ids = self.env['tenancy.rent.schedule'].search( [('tenancy_id', '=', record.id), ('paid', '=', False), ('move_check', '=', False)]) for value in rent_ids: value.write({'is_readonly': True}) return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def action_cancel(self):\n self.state = 'canceled'", "def cancel(self):\n self.__canceled = True", "def cancel(self):\n self.cancelled = True", "def cancel(self):\n self.cancelled = True", "def mark_cancelled(self):\n self.status = STATUS_CANCELED", "def on_cancel(self)...
[ "0.8116585", "0.7312937", "0.73086035", "0.73086035", "0.72557855", "0.717988", "0.7164008", "0.7164008", "0.7164008", "0.715947", "0.7138639", "0.71121854", "0.71121854", "0.71121854", "0.71017605", "0.7070211", "0.7022063", "0.7022063", "0.70071477", "0.69725823", "0.696377...
0.6651149
37
Create invoice for Rent Schedule.
def create_landlord_invoice(self): if self.tenancy_id.is_landlord_rent: account_jrnl_obj = self.env['account.journal'].search( [('type', '=', 'purchase')], limit=1) inv_lines_values = { # 'origin': 'tenancy.rent.schedule', 'name': 'Rent Cost for' + self.tenancy_id.name, 'quantity': 1, 'price_unit': self.amount or 0.00, 'account_id': self.tenancy_id.property_id.account_depreciation_expense_id.id or False, 'analytic_account_id': self.tenancy_id.id or False, } owner_rec = self.tenancy_id.property_owner_id invo_values = { 'partner_id': self.tenancy_id.property_owner_id.id or False, 'type': 'in_invoice', 'invoice_line_ids': [(0, 0, inv_lines_values)], 'property_id': self.tenancy_id.property_id.id or False, 'invoice_date': self.start_date or False, # 'account_id': owner_rec.property_account_payable_id.id, # 'schedule_id': self.id, 'new_tenancy_id': self.tenancy_id.id, 'journal_id': account_jrnl_obj.id or False } acc_id = self.env['account.move'].with_context({'default_type': 'in_invoice'}).create(invo_values) self.write({'invc_id': acc_id.id, 'inv': True}) wiz_form_id = self.env['ir.model.data'].get_object_reference( 'account', 'view_move_form')[1] return { 'view_type': 'form', 'view_id': wiz_form_id, 'view_mode': 'form', 'res_model': 'account.move', 'res_id': self.invc_id.id, 'type': 'ir.actions.act_window', 'target': 'current', 'context': self._context, }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _create_invoice(self):\n self.ensure_one()\n partner = self.member_id.partner_id\n invoice = self.env['account.invoice'].create({\n 'partner_id': partner.id,\n 'account_id': partner.property_account_receivable_id.id,\n 'fiscal_position_id': partner.property...
[ "0.69727474", "0.64852816", "0.6456974", "0.64502263", "0.6428501", "0.64010954", "0.63116646", "0.6295384", "0.6290846", "0.6239638", "0.6185124", "0.61704993", "0.6166009", "0.6165586", "0.6118279", "0.6118134", "0.5988207", "0.5985031", "0.594222", "0.5859622", "0.5817861"...
0.7042408
0
Formats a table from a nested list, where the first index is the row.
def list_to_table(lst, titles, margins=3, sort=True): if sort: lst = sorted(lst) result = '' margins = [margins,] * len(titles) if not hasattr(margins, '__iter__') else margins # establish column widths widths = [] for i in range(len(titles)): widths.append(max([len(titles[i]),] + [len(row[i]) for row in lst]) + margins[i]) # a base format string for every line linebase = '' for w in widths: linebase += ('%%-%ss'%w) # make the header result += linebase % tuple(titles) + '\n' result += '-' * sum(widths) + '\n' # add the table data for row in lst: result += linebase % tuple(row) + '\n' return result.strip()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format_table(table, format_str):\n ret = []\n for t in table:\n if type(t) is list:\n ret.append(format_table(t, format_str))\n else:\n ret.append(format_str.format(t))\n return ret", "def simple_format_table(table):\n s = [[str(e) for e in row] for row in tabl...
[ "0.7323263", "0.70893776", "0.7016123", "0.6676324", "0.6575941", "0.64442533", "0.6433064", "0.64183867", "0.6377864", "0.6365274", "0.6337073", "0.6316442", "0.6308462", "0.6291281", "0.6273893", "0.62692267", "0.6268458", "0.6246334", "0.6235649", "0.62235904", "0.62235904...
0.64111507
8
Handy function which splits a list of arguments and keyword arguments, translates names of Gadget instances to actual objects, evaluates expressions that can be evaluated, and accepts the rest as strings. For example,
def str_to_args(line): args_in = line.split() args_out = [] kwargs_out = {} gadget_lookup = {g.name: g for g in Gadget.getinstances()} for a in args_in: if '=' in a: key, val = a.split('=') if ('*' in val) or ('?' in val): matching_names = filter(gadget_lookup.keys(), val) kwargs_out[key] = [gadget_lookup[name] for name in matching_names] elif val in gadget_lookup.keys(): kwargs_out[key] = gadget_lookup[val] else: kwargs_out[key] = eval(val) else: if ('*' in a) or ('?' in a): matching_names = filter(gadget_lookup.keys(), a) args_out += [gadget_lookup[name] for name in matching_names] elif a in gadget_lookup.keys(): args_out.append(gadget_lookup[a]) else: try: args_out.append(eval(a)) except NameError: args_out.append(a) return args_out, kwargs_out
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def eval(*args, **kwargs):\n\n pass", "def eval(x, env):\n if isinstance(x, Symbol): # variable reference\n return env.find(x)[x]\n elif not isinstance(x, List): # constant literal\n return x\n keyword = x.pop()\n if keyword in {\"quote\", \"'\"}: # (quote exp)\n return (\n...
[ "0.5543349", "0.5514955", "0.54775155", "0.54402816", "0.5358683", "0.52867675", "0.5281894", "0.52406925", "0.52398866", "0.51826596", "0.51759326", "0.51671344", "0.51667196", "0.5136077", "0.51311547", "0.5085241", "0.5079983", "0.5065142", "0.49714673", "0.4969139", "0.49...
0.6068337
0
Return two title strings and a format string corresponding to
def format_pair(self, k, v): if isinstance(v, int): data_width = len(str(v)) + 1 header_width = len(str(k)) w = max(data_width, header_width) h = ('%% %us'%w)%k return ' '*len(h), h, '%%%ud'%w elif k=='dt': fmt = '%6.3f' return 6*' ', '%6s'%k, fmt elif isinstance(v, float): fmt = '% .3e' data_width = len(fmt%1) header_width = len(str(k)) w = max(data_width, header_width) spaces = ' '*(w-data_width) h = ('%%%us'%w)%k return ' '*len(h), h, spaces+fmt elif isinstance(v, dict): results = [self.format_pair(k_, v_) for k_, v_ in v.items()] keys = ' '.join([str(r[-2]) for r in results]) fmts = ' '.join([str(r[-1]) for r in results]) h1 = ('%%.%us'%(len(keys))) % k pl = (len(keys)-len(h1)) // 2 pr = (len(keys)-len(h1)) - pl h1 = '.' * pl + h1 + '.' * pr return h1, keys, fmts elif isinstance(v, h5py.ExternalLink): data_width = len('hdf5-link') header_width = len(str(k)) w = max(data_width, header_width) h = ('%%%us'%w)%k return ' '*len(h), h, '%%%us'%w elif isinstance(v, h5py.VirtualLayout): data_width = len('hdf5-vds') header_width = len(str(k)) w = max(data_width, header_width) h = ('%%%us'%w)%k return ' '*len(h), h, '%%%us'%w else: fmt = '%%%u.%us' % (self.min_str_len, self.max_str_len) w = len(fmt%v) h = ('%%%us'%w)%k return ' '*len(h), h, fmt
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_title(cfg, alias_1, attrs_1, alias_2=None, attrs_2=None,\n op_type='-'):\n if alias_2 is None:\n title = alias_1\n if cfg['years_in_title']:\n title += f\" ({attrs_1['start_year']}-{attrs_1['end_year']})\"\n return title\n if attrs_2 is None:\n ra...
[ "0.7094175", "0.6907892", "0.68420154", "0.6698707", "0.6661369", "0.6655837", "0.6552088", "0.6432714", "0.64024884", "0.6400669", "0.637345", "0.6352613", "0.6352252", "0.6263117", "0.61993533", "0.6197676", "0.6158429", "0.61383647", "0.61294615", "0.61219627", "0.61102825...
0.0
-1
Takes a data dict and returns a data line.
def fill_line(self, dct): return self._line_format % self.list_values(dct)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_line(self, line, data):\n return data", "def _plot_dict_line(d, label=None):\n xvals, yvals = _dict2lists(d)\n if label:\n pylab.plot(xvals, yvals, label=label)\n else:\n pylab.plot(xvals, yvals)", "def writeLine(self, data):\n raise NotImplementedError()", "d...
[ "0.6137988", "0.57134515", "0.5674397", "0.5633335", "0.55844647", "0.55069125", "0.54839", "0.5479354", "0.54715055", "0.537579", "0.53699166", "0.5352207", "0.5318781", "0.5310787", "0.52863955", "0.5243444", "0.5207458", "0.5203357", "0.5161909", "0.515372", "0.51435477", ...
0.56865346
2
if mouse is outside the window, the paddle will be at the edge.
def paddle_reset_position(self, mouse): if (0 + self.paddle.width / 2) <= mouse.x <= (self.window.width - self.paddle.width / 2): self.paddle_x = mouse.x - self.paddle.width / 2 self.window.add(self.paddle, self.paddle_x, self.paddle_y)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def paddle_moving(self, mouse):\n # when the paddle is in the window\n if 0 + self.paddle.width/2 <= mouse.x <= self.window.width - self.paddle.width/2:\n self.paddle.x = mouse.x - self.paddle.width / 2\n\n # when the paddle is about to leave the left side of the window\n eli...
[ "0.8009978", "0.70204043", "0.70202464", "0.693563", "0.66550136", "0.6435849", "0.6397138", "0.6362361", "0.63407254", "0.63133556", "0.6291798", "0.6267906", "0.6251655", "0.6229885", "0.61976296", "0.6141946", "0.6129163", "0.6072724", "0.6051235", "0.6037957", "0.59937733...
0.78187925
1
The first click (or revived click) starts the game, and the others no impact. onmouseclicked(self.click_check)
def click_check(self, mouse): self.cc += 1 return self.cc
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def start_game():\n logger.info(\"Clicking play button\")\n mouseclick(coords_play_final_button[0], coords_play_final_button[1])", "def play(self, event):\n if self.num_clicks == 1:\n self.clickable(event)\n if len(self.canvas.find_withtag(\"selected\")) == 2:\n ...
[ "0.7497747", "0.7181813", "0.698531", "0.6901437", "0.6851919", "0.68466634", "0.6759625", "0.65531003", "0.65473086", "0.6535983", "0.6518915", "0.6467115", "0.64507085", "0.64456236", "0.6402903", "0.6379502", "0.63639313", "0.6360009", "0.63344973", "0.6327313", "0.6322559...
0.5729173
99
Generate a document containing the available variable types.
def generate_type_hierarchy(ctx): ctx.run("./env/bin/python -m puresnmp.types > doc/typetree.rst")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def document_types(db: Session = Depends(get_db)):\n return get_document_types(db)", "def _variable_types(self):\n return self._variable_single_types + self._variable_array_types", "def doc_types(self):\n return self._extract_set('doc_type')", "def genotype(self):\n\t\tgenotype = \"\"\n\t\tf...
[ "0.61465466", "0.60761213", "0.5973325", "0.5913389", "0.5776444", "0.5673241", "0.56731915", "0.56657207", "0.56385726", "0.5612472", "0.55503535", "0.5506323", "0.5504591", "0.5486256", "0.5480814", "0.5403671", "0.54033583", "0.54031324", "0.5394926", "0.53930014", "0.5330...
0.6633607
0
Main method of the command.
def handle(self, *args, **options): self.create_indices() self.bulk()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main(args):", "def main(args):", "def cli():", "def cli():", "def cli():", "def cli():", "def cli():", "def cli():", "def cli():", "def cli():", "def cli():", "def cli():", "def cli():", "def cli():", "def cli():", "def cli():", "def cli():", "def cli():", "def cli():", "d...
[ "0.78725755", "0.78725755", "0.78080964", "0.78080964", "0.78080964", "0.78080964", "0.78080964", "0.78080964", "0.78080964", "0.78080964", "0.78080964", "0.78080964", "0.78080964", "0.78080964", "0.78080964", "0.78080964", "0.78080964", "0.78080964", "0.78080964", "0.78080964"...
0.0
-1
Create needed indices in Elasticsearch.
def create_indices(self) -> None: self.client.indices.create( index="business", body=BUSINESS_MAPPINGS ) self.client.indices.create( index="review", body=REVIEW_MAPPINGS ) self.client.indices.create( index="tip", body=TIP_MAPPINGS )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_indices():\n destroy_indices()\n\n ActionDocument._index.create(ignore=[400, 404])\n ClassificationDocument._index.create(ignore=[400, 404])\n FunctionDocument._index.create(ignore=[400, 404])\n PhaseDocument._index.create(ignore=[400, 404])\n RecordDocument._index.create(ignore=[400, ...
[ "0.7837676", "0.73570573", "0.735629", "0.7337516", "0.7260696", "0.72410965", "0.7223582", "0.7056203", "0.67365074", "0.6722053", "0.6716243", "0.6706365", "0.666678", "0.66666", "0.6647666", "0.6642432", "0.66221064", "0.6614326", "0.6584603", "0.656978", "0.649845", "0....
0.8065617
0
Bulk each JSON data into Elasticsearch.
def bulk(self) -> None: helpers.bulk(self.client, self.gen_business_data(BUSINESS_FP)) helpers.bulk(self.client, self.gen_review_data(REVIEW_FP)) helpers.bulk(self.client, self.gen_tip_data(TIP_FP))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post_bulk(bulk_json):\n\n nbtry=0\n success=False\n\n # Bulk insert\n ####################################################################\n cnx.request(\"POST\",config.index+\"/\"+config.typ+\"/_bulk\",bulk_json) #\n ###################################################...
[ "0.7087452", "0.70536715", "0.69762194", "0.6880638", "0.6755723", "0.6637794", "0.65397894", "0.63219965", "0.6277341", "0.6203022", "0.6132802", "0.6057554", "0.60138315", "0.5994877", "0.5978946", "0.5965338", "0.59499013", "0.5907674", "0.5890695", "0.5883793", "0.5879400...
0.57462233
28
Preprocess and generate business data.
def gen_business_data(fp: str) -> None: with open(fp, encoding='utf-8') as f: for line in f: data = json.loads(line) if "categories" in data.keys() and data["categories"]: data["categories"] = [s.strip() for s in data["categories"].split(',')] utils.preprocess_raw_json(data) utils.flatten_business_attributes(data) doc = { "_index": "business", "_source": data } yield doc
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pre_process(self):\n pass", "def pre_process(self):\n pass", "def pre_process(self):\n pass", "def pre_process(self):\n pass", "def pre_process(self):\n pass", "def preprocess(self):\n pass", "def preprocess(self):\n pass", "def preprocess(self):\n...
[ "0.7036312", "0.7036312", "0.7036312", "0.7036312", "0.7036312", "0.7025339", "0.7025339", "0.7025339", "0.6963976", "0.6953828", "0.6916517", "0.6750624", "0.661842", "0.66013443", "0.65898615", "0.65819675", "0.65424716", "0.6525521", "0.65110165", "0.64360577", "0.63551754...
0.0
-1
Preprocess and generate review data.
def gen_review_data(fp: str) -> None: with open(fp, encoding='utf-8') as f: for line in f: data = json.loads(line) utils.preprocess_raw_json(data) doc = { "_index": "review", "_source": data } yield doc
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prepare_data():\n user_name = os.environ.get('USER')\n traintest_corpus = ResumeCorpus('/Users/' + user_name + '/Documents/Data')\n random.shuffle(traintest_corpus.resumes)\n\n for resume in traintest_corpus.resumes:\n try:\n review_text = pre_processing(resume[0])\n re...
[ "0.7254628", "0.70474005", "0.69253355", "0.6693225", "0.6500812", "0.6482826", "0.64625686", "0.6401025", "0.6401025", "0.6401025", "0.63591665", "0.63579935", "0.63479227", "0.6305108", "0.6280583", "0.6279011", "0.62662226", "0.62520474", "0.6230281", "0.6212326", "0.61989...
0.6111473
24
Preprocess and generate tip data.
def gen_tip_data(fp: str) -> None: with open(fp, encoding='utf-8') as f: for line in f: data = json.loads(line) utils.preprocess_raw_json(data) doc = { "_index": "tip", "_source": data } yield doc
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def preProcess(self, datum):\n pass", "def preprocess(self, data, label):\n\t\traise NotImplementedError", "def _build_preprocessing(self):\n\n # For now, do nothing\n pass", "def preprocess(self):", "def _preprocess(self):\n self.data['sentences'] = self.data['text'].apply(self...
[ "0.6318788", "0.6080475", "0.60501426", "0.5997665", "0.58562475", "0.5852716", "0.5846063", "0.5846063", "0.5846063", "0.5781888", "0.56678724", "0.56678724", "0.56678724", "0.56678724", "0.56678724", "0.5593358", "0.55858773", "0.55671465", "0.55429596", "0.5542602", "0.552...
0.54621476
23
Generates a link allowing the data in a given panda dataframe to be downloaded
def filedownload(df): csv = df.to_csv(index=False) b64 = base64.b64encode(csv.encode()).decode() # some strings <-> bytes conversions necessary here href = f'<a href="data:file/csv;base64,{b64}" download="player.csv">Download csv file</a>' return href
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_table_download_link(df, file_name):\n if 'embedding_average' in df.columns:\n df = df.drop(columns='embedding_average')\n # df = results_output.drop(columns='embedding_average')\n # csv = df.to_csv(index=False)\n # b64 = base64.b64encode(csv.encode()).decode() # some strings <-> bytes c...
[ "0.7870279", "0.7813833", "0.770839", "0.7706421", "0.77046764", "0.7687905", "0.7659281", "0.7649181", "0.7642583", "0.76236206", "0.76104516", "0.7604595", "0.7596416", "0.7582703", "0.75675696", "0.7466063", "0.74483395", "0.73935926", "0.72894573", "0.68111026", "0.670160...
0.7307365
18
Computes the x coordinate of the ball
def getBallX(state): region = state[93:189, 8:WIDTH-8, 0] nonzero_x_coords = region.nonzero()[1] if len(nonzero_x_coords) > 0: return nonzero_x_coords.mean() return -1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_x(self):\n return self.position.x", "def get_x(self):\n\t\treturn self._collision_rect.x + 14", "def x(self):\r\n return self.position.x", "def get_x(self):\n return self.posX", "def get_pos_x(self):\n return self.__pos_x", "def Getxcoord(self):\n return self.x_coo...
[ "0.7201727", "0.7096933", "0.69620883", "0.69616777", "0.68398833", "0.6825444", "0.68012977", "0.68012977", "0.67890507", "0.67753965", "0.67356485", "0.6712596", "0.67017496", "0.6700496", "0.6699452", "0.6689949", "0.66789895", "0.6650196", "0.6637467", "0.6616907", "0.661...
0.7251717
0
Computes the x coordinate of the paddle.
def getPaddleX(state): region = state[190:191, 8:WIDTH-8, 0] nonzero_x_coords = region.nonzero()[1] assert len(nonzero_x_coords) > 0 return nonzero_x_coords.mean()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_x(self):\n return self.position.x", "def get_x(self):\n return self.posX", "def x(self):\r\n return self.position.x", "def get_pos_x(self):\n return self.__pos_x", "def get_x_position(self):\n return self.rect.x", "def get_alien_x(self):\n return self.x", ...
[ "0.7278048", "0.71396947", "0.70126045", "0.6951281", "0.69439006", "0.6811559", "0.6754752", "0.6747178", "0.674097", "0.6727758", "0.6699524", "0.6672045", "0.6648935", "0.66291857", "0.6610564", "0.6605478", "0.65597486", "0.65584433", "0.6536112", "0.6401617", "0.6386279"...
0.7158066
1
Maps state to an action. Move the paddle to be under the ball.
def getAction(self, state): ball_x = getBallX(state) paddle_x = getPaddleX(state) if ball_x == -1: # if ball not seen, move paddle to middle target_x = (WIDTH - 16)/2 else: target_x = ball_x if target_x < paddle_x: action = LEFT else: action = RIGHT if DEBUG: print "ball_x =", ball_x print "paddle_x =", paddle_x print "target_x =", target_x print "action =", action raw_input() return action
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _move_our_paddle(self, action) -> None:\n if not isinstance(action, int):\n action = action.item() # pops the item if the action is a single tensor\n assert action in [a for a in self.action_meanings.keys()], f\"{action} is not a valid action\"\n if action == self.actions['UP']...
[ "0.7522475", "0.6744767", "0.6475455", "0.63246346", "0.6307841", "0.63031274", "0.6293542", "0.6239462", "0.6162285", "0.6160075", "0.6146712", "0.6122981", "0.60952175", "0.6076362", "0.60531354", "0.60355747", "0.6020236", "0.5992324", "0.5984819", "0.5976522", "0.59671056...
0.6945269
1
Generates a credentials object for the current environment.
def get_credentials(): credentials, _project_id = google.auth.default(scopes=SCOPES) # Credentials from the GCloud SDK, for example, do not implement Signing. assert isinstance(credentials, google.auth.credentials.Signing), \ "Unsupported credential kind; credentials must implement Signing" return credentials
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def credentials():\n\n username = os.environ.get('OS_USERNAME')\n password = os.environ.get('OS_PASSWORD')\n tenant_name = (os.environ.get('OS_TENANT_NAME') or\n os.environ.get('OS_PROJECT_NAME'))\n auth_url = os.environ.get('OS_AUTH_URL')\n\n config = configparser.RawConfigParser(...
[ "0.7112774", "0.7041544", "0.7016884", "0.68389493", "0.68389493", "0.6838073", "0.683158", "0.68242747", "0.6818594", "0.6787863", "0.6783995", "0.67665184", "0.67437685", "0.66767615", "0.6668108", "0.6659616", "0.66587085", "0.66504437", "0.6628971", "0.66179526", "0.66133...
0.6263718
53
Deprecated. Alias for `get_credentials()`.
def get_appengine_credentials(): return get_credentials()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_credentials(self):\n return self.credentials", "def GetUserCredentials():\n email = options.email\n if email is None:\n email = GetEmail(\"Email (login for uploading to %s)\" % options.server)\n password = getpass.getpass(\"Password for %s: \" % email)\n return (email, password)",...
[ "0.6579635", "0.6387039", "0.63844115", "0.63098377", "0.6289624", "0.6281468", "0.62561184", "0.62231666", "0.61097383", "0.60903406", "0.60723895", "0.60612416", "0.60548604", "0.60009325", "0.5988076", "0.5980738", "0.5970519", "0.59341145", "0.59061664", "0.5883298", "0.5...
0.67769206
0
Generate a Credentials object from a key file.
def get_service_key_credentials(key_file_path): return service_account.Credentials.from_service_account_file( key_file_path, scopes=SCOPES, )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def from_file(cls, filename, **kwargs):\n return super(Credentials, cls).from_file(filename, **kwargs)", "def _GetCredentials():\n return service_account.Credentials.from_service_account_file(\n KEY_FILE, scopes=_SCOPES)", "def from_json_file(cls, filename: str):\n # Import standard modules...
[ "0.7308526", "0.70017743", "0.65263546", "0.65192187", "0.64679414", "0.64679414", "0.64656276", "0.64656276", "0.64656276", "0.6400258", "0.6367309", "0.6249415", "0.6246309", "0.6221481", "0.621487", "0.621381", "0.6206755", "0.6169671", "0.61067", "0.6066779", "0.6063209",...
0.6788051
2
Decode a token on AppEngine.
def decode_token_appengine(credentials, token, verify=False): return _decode_token(credentials, token, False)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def decode_token(token):\n decoded_token = jwt.decode(token, secret_key, algorithms=['HS256'])\n return decoded_token", "def decode(token):\n return jwt.decode(token, app.config[\"JWT_SECRET\"], algorithms=[\"HS256\"])", "def decode_token(token):\n\n return jwt.decode(\n token, setti...
[ "0.7735959", "0.76498765", "0.7568022", "0.74440914", "0.7167301", "0.7050499", "0.69980633", "0.69808865", "0.69499743", "0.6901275", "0.6866966", "0.6856232", "0.6854413", "0.68307525", "0.6819554", "0.68003577", "0.6735397", "0.66739464", "0.66599023", "0.665144", "0.66058...
0.7571242
2
Decode a token from a service account.
def decode_token_service_key(credentials, token, verify=True): return _decode_token(credentials, token, verify)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def decode_token(token):\n decoded_token = jwt.decode(token, secret_key, algorithms=['HS256'])\n return decoded_token", "def decode_token(token, options=JWT_OPTIONS):\n return jwt.decode(\n token,\n SECRET_KEY,\n issuer=JWT_ISSUER,\n audience=JWT_AUDIENCE,\n options=op...
[ "0.7157648", "0.7092701", "0.70881104", "0.6925482", "0.6889764", "0.6852807", "0.6839684", "0.673713", "0.6725172", "0.6700684", "0.6668323", "0.6648689", "0.65112424", "0.6478294", "0.6444482", "0.6437185", "0.6422741", "0.64142865", "0.63824797", "0.63795084", "0.63528466"...
0.74529535
0
This function is to stop the spider
def spider_idle(self): self.logger.info('the queue is empty, wait for one minute to close the spider') time.sleep(30) req = self.next_requests() if req: self.schedule_next_requests() else: self.crawler.engine.close_spider(self, reason='finished')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def spider_closing(spider):\n print(\"Spiderclose\"*10)\n #reactor.stop()", "def stop(self):", "def stop(self):", "def _stop(self):", "def stop(self) -> None:\n ...", "def stop(self) -> None:", "def stop(self) -> None:", "def stop(self):\r\n pass", "def stop(...
[ "0.7635541", "0.75889057", "0.75889057", "0.74974936", "0.7481087", "0.7463915", "0.7463915", "0.7407182", "0.74046713", "0.7344371", "0.73300225", "0.73300225", "0.73300225", "0.73300225", "0.73190135", "0.73190135", "0.73190135", "0.73190135", "0.73190135", "0.73190135", "0...
0.0
-1
Q to SSH This code solve a linear system of equations using Conjugate Gradient method
def pv2ssh(lon, lat, q, hg, c, nitr=1, name_grd=''): def compute_avec(vec,aaa,bbb,grd): avec=np.empty(grd.np0,) avec[grd.vp2] = aaa[grd.vp2]*((vec[grd.vp2e]+vec[grd.vp2w]-2*vec[grd.vp2])/(grd.dx1d[grd.vp2]**2)+(vec[grd.vp2n]+vec[grd.vp2s]-2*vec[grd.vp2])/(grd.dy1d[grd.vp2]**2)) + bbb[grd.vp2]*vec[grd.vp2] avec[grd.vp1] = vec[grd.vp1] return avec, if name_grd is not None: if os.path.isfile(name_grd): with open(name_grd, 'rb') as f: grd = pickle.load(f) else: grd = Grid(lon,lat) with open(name_grd, 'wb') as f: pickle.dump(grd, f) f.close() else: grd = Grid(lon,lat) ny,nx,=np.shape(hg) g=grd.g x=hg[grd.indi,grd.indj] q1d=q[grd.indi,grd.indj] aaa=g/grd.f01d bbb=-g*grd.f01d/c**2 ccc=+q1d aaa[grd.vp1]=0 bbb[grd.vp1]=1 ccc[grd.vp1]=x[grd.vp1] ##boundary condition vec=+x avec,=compute_avec(vec,aaa,bbb,grd) gg=avec-ccc p=-gg for itr in range(nitr-1): vec=+p avec,=compute_avec(vec,aaa,bbb,grd) tmp=np.dot(p,avec) if tmp!=0. : s=-np.dot(p,gg)/tmp else: s=1. a1=np.dot(gg,gg) x=x+s*p vec=+x avec,=compute_avec(vec,aaa,bbb,grd) gg=avec-ccc a2=np.dot(gg,gg) if a1!=0: beta=a2/a1 else: beta=1. p=-gg+beta*p vec=+p avec,=compute_avec(vec,aaa,bbb,grd) val1=-np.dot(p,gg) val2=np.dot(p,avec) if (val2==0.): s=1. else: s=val1/val2 a1=np.dot(gg,gg) x=x+s*p # back to 2D h=np.empty((ny,nx)) h[:,:]=np.NAN h[grd.indi,grd.indj]=x[:] return h
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def preCondConjugateGradientSolver(b, x, linsys_setup, eps, i_max, plotInterval, mapDir):\n datamaps, ninvs, beams, freqs, power_2d, precond_2d, clumaps, g_nu, \\\n map_prop = linsys_setup\n nx, ny, pixScaleX, pixScaleY = map_prop\n nCluster = len(clumaps[0])\n ...
[ "0.71288806", "0.65124166", "0.63342714", "0.62315416", "0.62032104", "0.61986536", "0.61747384", "0.6161469", "0.6153835", "0.61255676", "0.6096203", "0.6096203", "0.6096203", "0.6096203", "0.6096203", "0.6096203", "0.6096203", "0.6096203", "0.6096203", "0.6096203", "0.60962...
0.0
-1
_masked_edge mask the edges of the swath gap
def _masked_edge(var,xac): if np.any(xac>0): ind_gap = (xac==np.nanmin(xac[xac>0])) if ind_gap.size==var.size: if ind_gap.shape!=var.shape: ind_gap = ind_gap.transpose() var[ind_gap] = np.nan elif ind_gap.size==var.shape[1]: var[:,ind_gap] = np.nan if np.any(xac<0): ind_gap = (xac==np.nanmax(xac[xac<0])) if ind_gap.size==var.size: if ind_gap.shape!=var.shape: ind_gap = ind_gap.transpose() var[ind_gap] = np.nan elif ind_gap.size==var.shape[1]: var[:,ind_gap] = np.nan return var
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subgraph_mask(self, size):\n init_matrix = np.random.randn(size,size)\n Tcs = csgraph.minimum_spanning_tree(init_matrix)\n mask_matrix = Tcs.toarray()\n return mask_matrix", "def mask(self):", "def mask(self):\n mask = np.zeros((self.height, self.width))\n pts = [\...
[ "0.6540822", "0.6309648", "0.6181867", "0.59951514", "0.5955324", "0.5927942", "0.5888009", "0.5813421", "0.57741016", "0.5771686", "0.57375604", "0.57116854", "0.57070524", "0.570407", "0.57027954", "0.5653326", "0.56071967", "0.5605403", "0.55971795", "0.5577067", "0.556996...
0.7204979
0
Given a node, visits the node using `visitor`. If removal is attempted by the visitor, an exception is raised.
def visit_required( parent: "CSTNode", fieldname: str, node: CSTNodeT, visitor: "CSTVisitorT" ) -> CSTNodeT: visitor.on_visit_attribute(parent, fieldname) result = node.visit(visitor) if isinstance(result, RemovalSentinel): raise TypeError( f"We got a RemovalSentinel while visiting a {type(node).__name__}. This " + "node's parent does not allow it to be removed." ) elif isinstance(result, FlattenSentinel): raise TypeError( f"We got a FlattenSentinel while visiting a {type(node).__name__}. This " + "node's parent does not allow for it to be it to be replaced with a " + "sequence." ) visitor.on_leave_attribute(parent, fieldname) return result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def removeNode(self, node):", "def depart(visitor: DocxTranslator, node: Node):\n assert isinstance(visitor, DocxTranslator)\n assert isinstance(node, Node)", "def depart(visitor: DocxTranslator, node: Node):\n assert isinstance(visitor, DocxTranslator)\n assert isinstance(node, Node)\n\n visito...
[ "0.66534734", "0.6408771", "0.6175824", "0.61187774", "0.60823214", "0.60546935", "0.60546935", "0.60546935", "0.60546935", "0.60546935", "0.6018935", "0.6014195", "0.6013895", "0.59864545", "0.59284323", "0.59193057", "0.5896044", "0.589552", "0.58731836", "0.5853483", "0.58...
0.0
-1
Given an optional node, visits the node if it exists with `visitor`. If the node is removed, returns None.
def visit_optional( parent: "CSTNode", fieldname: str, node: Optional[CSTNodeT], visitor: "CSTVisitorT" ) -> Optional[CSTNodeT]: if node is None: visitor.on_visit_attribute(parent, fieldname) visitor.on_leave_attribute(parent, fieldname) return None visitor.on_visit_attribute(parent, fieldname) result = node.visit(visitor) if isinstance(result, FlattenSentinel): raise TypeError( f"We got a FlattenSentinel while visiting a {type(node).__name__}. This " + "node's parent does not allow for it to be it to be replaced with a " + "sequence." ) visitor.on_leave_attribute(parent, fieldname) return None if isinstance(result, RemovalSentinel) else result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def depart(visitor: DocxTranslator, node: Node):\n assert isinstance(visitor, DocxTranslator)\n assert isinstance(node, Node)\n\n visitor.p = None", "def get_visitor(self, node: Node) -> \"t.Optional[VisitCallable]\":\n return getattr(self, f\"visit_{type(node).__name__}\", None)", "def or_none...
[ "0.6102222", "0.5962804", "0.583166", "0.5687837", "0.56851536", "0.56654507", "0.55203897", "0.54365003", "0.54352176", "0.5417704", "0.53179693", "0.5272227", "0.5247078", "0.52446026", "0.52202773", "0.51991373", "0.51991373", "0.51991373", "0.51991373", "0.51991373", "0.5...
0.58078337
3
Given a node that can be a real value or a sentinel value, visits the node if it is real with `visitor`. If the node is removed, returns MaybeSentinel.
def visit_sentinel( parent: "CSTNode", fieldname: str, node: Union[CSTNodeT, MaybeSentinel], visitor: "CSTVisitorT", ) -> Union[CSTNodeT, MaybeSentinel]: if isinstance(node, MaybeSentinel): visitor.on_visit_attribute(parent, fieldname) visitor.on_leave_attribute(parent, fieldname) return MaybeSentinel.DEFAULT visitor.on_visit_attribute(parent, fieldname) result = node.visit(visitor) if isinstance(result, FlattenSentinel): raise TypeError( f"We got a FlattenSentinel while visiting a {type(node).__name__}. This " + "node's parent does not allow for it to be it to be replaced with a " + "sequence." ) visitor.on_leave_attribute(parent, fieldname) return MaybeSentinel.DEFAULT if isinstance(result, RemovalSentinel) else result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def visit_optional(\n parent: \"CSTNode\", fieldname: str, node: Optional[CSTNodeT], visitor: \"CSTVisitorT\"\n) -> Optional[CSTNodeT]:\n if node is None:\n visitor.on_visit_attribute(parent, fieldname)\n visitor.on_leave_attribute(parent, fieldname)\n return None\n visitor.on_visit_a...
[ "0.59443796", "0.56053245", "0.5583689", "0.54266834", "0.52108747", "0.5164809", "0.5164809", "0.5084462", "0.50170124", "0.49877784", "0.49669993", "0.49597752", "0.48452675", "0.48225835", "0.47906753", "0.47757596", "0.47500685", "0.47187987", "0.47036573", "0.46635467", ...
0.63893396
0
Given an iterable of children, visits each child with `visitor`, and yields the new children with any `RemovalSentinel` values removed.
def visit_iterable( parent: "CSTNode", fieldname: str, children: Iterable[CSTNodeT], visitor: "CSTVisitorT", ) -> Iterable[CSTNodeT]: visitor.on_visit_attribute(parent, fieldname) for child in children: new_child = child.visit(visitor) if isinstance(new_child, FlattenSentinel): yield from new_child elif not isinstance(new_child, RemovalSentinel): yield new_child visitor.on_leave_attribute(parent, fieldname)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def visit_body_iterable(\n parent: \"CSTNode\",\n fieldname: str,\n children: Sequence[CSTNodeT],\n visitor: \"CSTVisitorT\",\n) -> Iterable[CSTNodeT]:\n\n visitor.on_visit_attribute(parent, fieldname)\n for child in children:\n new_child = child.visit(visitor)\n\n # Don't yield a c...
[ "0.742417", "0.596061", "0.59555763", "0.5783024", "0.5576109", "0.5383288", "0.5338851", "0.5332447", "0.5312418", "0.5300283", "0.52990466", "0.52795494", "0.5277477", "0.5260708", "0.5232784", "0.5212718", "0.5207777", "0.52073103", "0.5153014", "0.5149678", "0.5128579", ...
0.71860904
1
A convenience wrapper for `visit_iterable` that returns a sequence instead of an iterable.
def visit_sequence( parent: "CSTNode", fieldname: str, children: Sequence[CSTNodeT], visitor: "CSTVisitorT", ) -> Sequence[CSTNodeT]: return tuple(visit_iterable(parent, fieldname, children, visitor))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def toiter(x):\n if iterable(x):\n return x\n else:\n return [x]", "def concrete(seq):\n if isinstance(seq, Iterator):\n seq = list(seq)\n if isinstance(seq, (tuple, list)):\n seq = list(map(concrete, seq))\n return seq", "def make_iterable(arg):\n return arg if is...
[ "0.71035177", "0.6873974", "0.66026473", "0.64714134", "0.61446095", "0.61344165", "0.61129576", "0.60355216", "0.60355216", "0.5988719", "0.5987896", "0.5984973", "0.5884642", "0.58802277", "0.5814334", "0.5812307", "0.57950664", "0.57258046", "0.56900185", "0.56784594", "0....
0.5409288
40
Similar to visit_iterable above, but capable of discarding empty SimpleStatementLine nodes in order to preserve correct pass insertion behavior.
def visit_body_iterable( parent: "CSTNode", fieldname: str, children: Sequence[CSTNodeT], visitor: "CSTVisitorT", ) -> Iterable[CSTNodeT]: visitor.on_visit_attribute(parent, fieldname) for child in children: new_child = child.visit(visitor) # Don't yield a child if we removed it. if isinstance(new_child, RemovalSentinel): continue # Don't yield a child if the old child wasn't empty # and the new child is. This means a RemovalSentinel # caused a child of this node to be dropped, and it # is now useless. if isinstance(new_child, FlattenSentinel): for child_ in new_child: if (not child._is_removable()) and child_._is_removable(): continue yield child_ else: if (not child._is_removable()) and new_child._is_removable(): continue # Safe to yield child in this case. yield new_child visitor.on_leave_attribute(parent, fieldname)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def visit_simple_stmt(self, node: Node) -> Iterator[Line]:\n prev_type: Optional[int] = None\n for child in node.children:\n if (prev_type is None or prev_type == token.SEMI) and is_arith_like(child):\n wrap_in_parentheses(node, child, visible=False)\n prev_type =...
[ "0.6896916", "0.58363104", "0.5718831", "0.57141036", "0.5682867", "0.55000716", "0.55000716", "0.55000716", "0.55000716", "0.55000716", "0.55000716", "0.55000716", "0.55000716", "0.55000716", "0.55000716", "0.55000716", "0.55000716", "0.55000716", "0.55000716", "0.55000716", ...
0.4621964
94
A convenience wrapper for `visit_body_iterable` that returns a sequence instead of an iterable.
def visit_body_sequence( parent: "CSTNode", fieldname: str, children: Sequence[CSTNodeT], visitor: "CSTVisitorT", ) -> Sequence[CSTNodeT]: return tuple(visit_body_iterable(parent, fieldname, children, visitor))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def concrete(seq):\n if isinstance(seq, Iterator):\n seq = list(seq)\n if isinstance(seq, (tuple, list)):\n seq = list(map(concrete, seq))\n return seq", "def make_iterable(arg):\n return arg if is_iterable(arg) else (arg,)", "def toiter(x):\n if iterable(x):\n return x\n ...
[ "0.628293", "0.5938098", "0.59329444", "0.5872919", "0.5857194", "0.5846575", "0.5786622", "0.578137", "0.5776865", "0.5740671", "0.5727584", "0.57273525", "0.5643586", "0.5643586", "0.56330574", "0.55489177", "0.55487835", "0.5492281", "0.5490387", "0.5448653", "0.5433615", ...
0.60773885
1
make generic 2d drawer
def makeDrawer(self,node): drawer = MeshDrawer2D() drawer.setBudget(3000) drawerNode = drawer.getRoot() drawerNode.reparentTo(node) drawerNode.setDepthWrite(False) drawerNode.setTransparency(True) drawerNode.setTwoSided(True) drawerNode.setBin("fixed",0) drawerNode.setLightOff(True) drawerNode.node().setBounds(OmniBoundingVolume()) drawerNode.node().setFinal(True) # debug wire frame #cc = drawerNode.copyTo(node) #cc.setRenderModeWireframe() return drawer
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw():", "def draw_walker(indx):\n chart_1.create_oval(hips[indx]-6, hips[indx+1]-6,hips[indx]+6, hips[indx+1]+6, fill= \"magenta\", width = 1, tag = 'line_1') \n chart_1.create_line(hips[indx], hips[indx+1], knee_a[indx], knee_a[indx+1], fill= \"blue\", width = 2, tag = 'line_1') \n chart_1.create...
[ "0.5789169", "0.57169425", "0.5665617", "0.5664664", "0.56565046", "0.5645116", "0.5549842", "0.5513326", "0.54959905", "0.54648364", "0.5380513", "0.5378376", "0.53420097", "0.52914715", "0.52714217", "0.5257676", "0.5251487", "0.52281845", "0.52245355", "0.5197554", "0.5197...
0.68525183
0
make the theme drawer
def makeThemeDrawer(self,node): themeDrawer = self.makeDrawer(node) themeDrawer.getRoot().setTexture(self.image) return themeDrawer
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main(themes):\n # Get toggled mode based on current system mode.\n toggled_mode = get_toggled_mode(get_current_mode())\n print('\\nSetting themes...')\n\n for theme in themes:\n # Set toggled mode.\n theme.mode = toggled_mode\n theme.toggle_callback(theme)\n if IS_WINDOWS:\n...
[ "0.5896766", "0.56492335", "0.5608493", "0.5590127", "0.55801094", "0.54546154", "0.54343575", "0.5407063", "0.540511", "0.5388838", "0.5362931", "0.5360915", "0.53588575", "0.5346011", "0.5341834", "0.5332074", "0.5331664", "0.53218496", "0.52839094", "0.52213657", "0.519646...
0.75262403
0
draws all of the children
def draw(self,children): self.clip = [(0,0,gui._width+100, gui._height+100)] self.drawer.setClip(0,0,gui._width+100, gui._height+100) self.drawer.begin() z = 0 for child in reversed(children): z += 1 self.drawChild(0,0,z,child) self.drawer.end()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw(self, force=False):\n for child in self.children.values():\n child.draw(force)", "def draw(self):\n for obj in self.objects:\n obj.draw()", "def draw(self):\n for tree_idx, tree in enumerate(self.trees):\n print(\"==================================...
[ "0.8111126", "0.7670635", "0.7543276", "0.7344588", "0.72956795", "0.7167588", "0.70602024", "0.70129067", "0.70129067", "0.70129067", "0.70129067", "0.70129067", "0.70129067", "0.70129067", "0.70129067", "0.69427055", "0.6871382", "0.68627614", "0.6847094", "0.67624927", "0....
0.82077765
0
draws a single thing
def drawChild(self,x,y,z,thing): self.z = z if not thing.visable: return self.color = Vec4(*thing.color) realX = x+float(thing._x) realY = y+float(thing._y) if thing.style: style = gui.theme.define(thing.style) if style: style.draw( self, (realX,realY), (float(thing._width),float(thing._height))) if thing.clips: # set clip stuff self.pushClip(realX,realY,realX+thing._width,realY+thing._height) if thing.icon: rect = self.atlas.getRect(thing.icon) if rect: self.color = thing.color u,v,us,vs = rect self.rectStreatch((realX,realY,us,vs),(u,v,us,vs)) if thing.text: # draw text stuff if thing.editsText: self.drawEditText( gui.theme.defineFont(thing.font), thing.text, realX, realY, thing.selection, thing.caret) else: self.drawText( gui.theme.defineFont(thing.font), thing.text, realX, realY) if thing.children: for child in thing.children: z += 1 self.drawChild(realX,realY,z,child) if thing.clips: self.popClip()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw():", "def draw( self, **kw ):\n pass", "def draw(self):\n pass", "def draw(self):\n pass", "def draw(self):\n pass", "def draw(self):\n pass", "def draw(self) -> Any:", "def draw(self):", "def draw(self):\n\t\tpass", "def game_draw(self):\n pass"...
[ "0.77985585", "0.74365014", "0.7152805", "0.7152805", "0.7152805", "0.7152805", "0.7134484", "0.7120514", "0.70584196", "0.6996481", "0.6867047", "0.68482596", "0.6772941", "0.67679566", "0.67679566", "0.67679566", "0.67469466", "0.6740048", "0.67351854", "0.66578966", "0.665...
0.62185705
58
draws the text and selection and caret
def drawEditText(self, font, text, x, y, selection=(0,0), caret=-1): self.color = Vec4(*font.color) name = font.name char_count = 0 ox = x baseLetter = self.atlas.getChar(name + str(ord("T"))) omaxh = baseLetter[3] - baseLetter[4][1] for line in text.split("\n"): build = [] maxh = omaxh for c in line: if char_count == caret: u,v,w,h,e = self.atlas.getChar(name + str(ord('|'))) build.append((x-w/2,y+e[1],u,v,w,h)) char_count += 1 code = ord(c) if code <= 32: u,v,w,h,e = self.atlas.getChar(name + str(77)) x += e[0] continue u,v,w,h,e = self.atlas.getChar(name + str(code)) build.append((x,y+e[1],u,v,w,h)) x += e[0] maxh = max(maxh,h-e[1]) else: if char_count == caret: u,v,w,h,e = self.atlas.getChar(name + str(ord('|'))) build.append((x-w/2,y+e[1],u,v,w,h)) char_count += 1 for x,y,u,v,w,h in build: self.rectStreatch((x,y+maxh-h,w,h),(u,v,w,h)) x = ox y += maxh
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw(self):\n if self.dirty:\n self._render()\n for text in self.text_lines:\n text.draw()", "def draw(self, win):\n self.rect.draw(win)\n self.text.draw(win)", "def text_draw(self, x, y, text, style={}):", "def draw(self, screen):\n lines = self.t...
[ "0.7433061", "0.7251996", "0.72452176", "0.7009771", "0.69782376", "0.6925863", "0.6890717", "0.6733484", "0.66595197", "0.6654603", "0.6588631", "0.65804046", "0.65804046", "0.65804046", "0.65804046", "0.6565332", "0.65605956", "0.6522511", "0.650832", "0.64866877", "0.64705...
0.72526735
1