id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
7,000 | limodou/uliweb | uliweb/orm/__init__.py | Model._get_data | def _get_data(self, fields=None, compare=True):
"""
Get the changed property, it'll be used to save the object
If compare is False, then it'll include all data not only changed property
"""
fields = fields or []
if self._key is None or self._key == '' or self._key == 0:
... | python | def _get_data(self, fields=None, compare=True):
"""
Get the changed property, it'll be used to save the object
If compare is False, then it'll include all data not only changed property
"""
fields = fields or []
if self._key is None or self._key == '' or self._key == 0:
... | [
"def",
"_get_data",
"(",
"self",
",",
"fields",
"=",
"None",
",",
"compare",
"=",
"True",
")",
":",
"fields",
"=",
"fields",
"or",
"[",
"]",
"if",
"self",
".",
"_key",
"is",
"None",
"or",
"self",
".",
"_key",
"==",
"''",
"or",
"self",
".",
"_key"... | Get the changed property, it'll be used to save the object
If compare is False, then it'll include all data not only changed property | [
"Get",
"the",
"changed",
"property",
"it",
"ll",
"be",
"used",
"to",
"save",
"the",
"object",
"If",
"compare",
"is",
"False",
"then",
"it",
"ll",
"include",
"all",
"data",
"not",
"only",
"changed",
"property"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/orm/__init__.py#L3967-L4016 |
7,001 | limodou/uliweb | uliweb/orm/__init__.py | Model.create_sql | def create_sql(self, insert=False, version=False, version_fieldname=None,
fields=None, ec=None, compare=False):
"""
Create sql statement, do not process manytomany
"""
version_fieldname = version_fieldname or 'version'
#fix when d is empty, orm will not insert ... | python | def create_sql(self, insert=False, version=False, version_fieldname=None,
fields=None, ec=None, compare=False):
"""
Create sql statement, do not process manytomany
"""
version_fieldname = version_fieldname or 'version'
#fix when d is empty, orm will not insert ... | [
"def",
"create_sql",
"(",
"self",
",",
"insert",
"=",
"False",
",",
"version",
"=",
"False",
",",
"version_fieldname",
"=",
"None",
",",
"fields",
"=",
"None",
",",
"ec",
"=",
"None",
",",
"compare",
"=",
"False",
")",
":",
"version_fieldname",
"=",
"v... | Create sql statement, do not process manytomany | [
"Create",
"sql",
"statement",
"do",
"not",
"process",
"manytomany"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/orm/__init__.py#L4202-L4231 |
7,002 | limodou/uliweb | uliweb/orm/__init__.py | Model.get_collection_name | def get_collection_name(cls, from_class_name, collection_name=None, prefix=None):
"""
Get reference collection_name, if the collection_name is None
then make sure the collection_name is not conflict, but
if the collection_name is not None, then check if the collection_name
is alr... | python | def get_collection_name(cls, from_class_name, collection_name=None, prefix=None):
"""
Get reference collection_name, if the collection_name is None
then make sure the collection_name is not conflict, but
if the collection_name is not None, then check if the collection_name
is alr... | [
"def",
"get_collection_name",
"(",
"cls",
",",
"from_class_name",
",",
"collection_name",
"=",
"None",
",",
"prefix",
"=",
"None",
")",
":",
"if",
"not",
"collection_name",
":",
"collection_name",
"=",
"prefix",
"+",
"'_set'",
"if",
"hasattr",
"(",
"cls",
",... | Get reference collection_name, if the collection_name is None
then make sure the collection_name is not conflict, but
if the collection_name is not None, then check if the collection_name
is already exists, if existed then raise Exception. | [
"Get",
"reference",
"collection_name",
"if",
"the",
"collection_name",
"is",
"None",
"then",
"make",
"sure",
"the",
"collection_name",
"is",
"not",
"conflict",
"but",
"if",
"the",
"collection_name",
"is",
"not",
"None",
"then",
"check",
"if",
"the",
"collection_... | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/orm/__init__.py#L4313-L4334 |
7,003 | limodou/uliweb | uliweb/orm/__init__.py | Model._use | def _use(cls, ec):
"""
underly implement of use
"""
# class ConnectModel(cls):
# pass
ConnectModel = type(cls.__name__, (cls,), {})
ConnectModel.tablename = cls.tablename
ConnectModel._base_class = cls
if isinstance(ec, (str, unicode)):
... | python | def _use(cls, ec):
"""
underly implement of use
"""
# class ConnectModel(cls):
# pass
ConnectModel = type(cls.__name__, (cls,), {})
ConnectModel.tablename = cls.tablename
ConnectModel._base_class = cls
if isinstance(ec, (str, unicode)):
... | [
"def",
"_use",
"(",
"cls",
",",
"ec",
")",
":",
"# class ConnectModel(cls):",
"# pass",
"ConnectModel",
"=",
"type",
"(",
"cls",
".",
"__name__",
",",
"(",
"cls",
",",
")",
",",
"{",
"}",
")",
"ConnectModel",
".",
"tablename",
"=",
"cls",
".",
"tab... | underly implement of use | [
"underly",
"implement",
"of",
"use"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/orm/__init__.py#L4413-L4428 |
7,004 | limodou/uliweb | uliweb/orm/__init__.py | Model.use | def use(cls, ec):
"""
use will duplicate a new Model class and bind ec
ec is Engine name or Sesstion object
"""
if isinstance(ec, (str, unicode)):
m = get_model(cls._alias, ec, signal=False)
else:
m = cls._use(ec)
return m | python | def use(cls, ec):
"""
use will duplicate a new Model class and bind ec
ec is Engine name or Sesstion object
"""
if isinstance(ec, (str, unicode)):
m = get_model(cls._alias, ec, signal=False)
else:
m = cls._use(ec)
return m | [
"def",
"use",
"(",
"cls",
",",
"ec",
")",
":",
"if",
"isinstance",
"(",
"ec",
",",
"(",
"str",
",",
"unicode",
")",
")",
":",
"m",
"=",
"get_model",
"(",
"cls",
".",
"_alias",
",",
"ec",
",",
"signal",
"=",
"False",
")",
"else",
":",
"m",
"="... | use will duplicate a new Model class and bind ec
ec is Engine name or Sesstion object | [
"use",
"will",
"duplicate",
"a",
"new",
"Model",
"class",
"and",
"bind",
"ec",
"ec",
"is",
"Engine",
"name",
"or",
"Sesstion",
"object"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/orm/__init__.py#L4431-L4442 |
7,005 | limodou/uliweb | uliweb/orm/__init__.py | Model.get_tree | def get_tree(cls, *condition, **kwargs):
"""
parent is root parent value, default is None
current is current value
condition is extra condition for select root records
mode is search method, value is 'wide' or 'deep'
"""
parent_field = kwargs.pop('parent_field', '... | python | def get_tree(cls, *condition, **kwargs):
"""
parent is root parent value, default is None
current is current value
condition is extra condition for select root records
mode is search method, value is 'wide' or 'deep'
"""
parent_field = kwargs.pop('parent_field', '... | [
"def",
"get_tree",
"(",
"cls",
",",
"*",
"condition",
",",
"*",
"*",
"kwargs",
")",
":",
"parent_field",
"=",
"kwargs",
".",
"pop",
"(",
"'parent_field'",
",",
"'parent'",
")",
"parent",
"=",
"kwargs",
".",
"pop",
"(",
"'parent'",
",",
"None",
")",
"... | parent is root parent value, default is None
current is current value
condition is extra condition for select root records
mode is search method, value is 'wide' or 'deep' | [
"parent",
"is",
"root",
"parent",
"value",
"default",
"is",
"None",
"current",
"is",
"current",
"value",
"condition",
"is",
"extra",
"condition",
"for",
"select",
"root",
"records",
"mode",
"is",
"search",
"method",
"value",
"is",
"wide",
"or",
"deep"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/orm/__init__.py#L4628-L4672 |
7,006 | limodou/uliweb | uliweb/orm/__init__.py | Model.refresh | def refresh(self, fields=None, **kwargs):
"""
Re get the instance of current id
"""
cond = self.c[self._primary_field]==self._key
query = self.filter(cond, **kwargs)
if not fields:
fields = list(self.table.c)
v = query.values_one(*fields)
... | python | def refresh(self, fields=None, **kwargs):
"""
Re get the instance of current id
"""
cond = self.c[self._primary_field]==self._key
query = self.filter(cond, **kwargs)
if not fields:
fields = list(self.table.c)
v = query.values_one(*fields)
... | [
"def",
"refresh",
"(",
"self",
",",
"fields",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"cond",
"=",
"self",
".",
"c",
"[",
"self",
".",
"_primary_field",
"]",
"==",
"self",
".",
"_key",
"query",
"=",
"self",
".",
"filter",
"(",
"cond",
","... | Re get the instance of current id | [
"Re",
"get",
"the",
"instance",
"of",
"current",
"id"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/orm/__init__.py#L4744-L4759 |
7,007 | limodou/uliweb | uliweb/orm/__init__.py | Model.dump | def dump(self, fields=None, exclude=None):
"""
Dump current object to dict, but the value is string
for manytomany fields will not automatically be dumpped, only when
they are given in fields parameter
"""
exclude = exclude or []
d = {}
if fields and self.... | python | def dump(self, fields=None, exclude=None):
"""
Dump current object to dict, but the value is string
for manytomany fields will not automatically be dumpped, only when
they are given in fields parameter
"""
exclude = exclude or []
d = {}
if fields and self.... | [
"def",
"dump",
"(",
"self",
",",
"fields",
"=",
"None",
",",
"exclude",
"=",
"None",
")",
":",
"exclude",
"=",
"exclude",
"or",
"[",
"]",
"d",
"=",
"{",
"}",
"if",
"fields",
"and",
"self",
".",
"_primary_field",
"not",
"in",
"fields",
":",
"fields"... | Dump current object to dict, but the value is string
for manytomany fields will not automatically be dumpped, only when
they are given in fields parameter | [
"Dump",
"current",
"object",
"to",
"dict",
"but",
"the",
"value",
"is",
"string",
"for",
"manytomany",
"fields",
"will",
"not",
"automatically",
"be",
"dumpped",
"only",
"when",
"they",
"are",
"given",
"in",
"fields",
"parameter"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/orm/__init__.py#L4802-L4828 |
7,008 | limodou/uliweb | uliweb/orm/__init__.py | Model.clear_relation | def clear_relation(cls):
"""
Clear relation properties for reference Model, such as OneToOne, Reference,
ManyToMany
"""
for k, v in cls.properties.items():
if isinstance(v, ReferenceProperty):
if hasattr(v, 'collection_name') and hasattr(v.reference_cl... | python | def clear_relation(cls):
"""
Clear relation properties for reference Model, such as OneToOne, Reference,
ManyToMany
"""
for k, v in cls.properties.items():
if isinstance(v, ReferenceProperty):
if hasattr(v, 'collection_name') and hasattr(v.reference_cl... | [
"def",
"clear_relation",
"(",
"cls",
")",
":",
"for",
"k",
",",
"v",
"in",
"cls",
".",
"properties",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"ReferenceProperty",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"'collection_name'",
"... | Clear relation properties for reference Model, such as OneToOne, Reference,
ManyToMany | [
"Clear",
"relation",
"properties",
"for",
"reference",
"Model",
"such",
"as",
"OneToOne",
"Reference",
"ManyToMany"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/orm/__init__.py#L4840-L4852 |
7,009 | limodou/uliweb | uliweb/orm/__init__.py | Bulk.put | def put(self, _name, **values):
"""
Put data to cach, if reached size value, it'll execute at once.
"""
try:
sql = self.sqles[_name]
data = sql['data']
if sql['positional']:
d = [values[k] for k, v in sql['fields'].items()]
... | python | def put(self, _name, **values):
"""
Put data to cach, if reached size value, it'll execute at once.
"""
try:
sql = self.sqles[_name]
data = sql['data']
if sql['positional']:
d = [values[k] for k, v in sql['fields'].items()]
... | [
"def",
"put",
"(",
"self",
",",
"_name",
",",
"*",
"*",
"values",
")",
":",
"try",
":",
"sql",
"=",
"self",
".",
"sqles",
"[",
"_name",
"]",
"data",
"=",
"sql",
"[",
"'data'",
"]",
"if",
"sql",
"[",
"'positional'",
"]",
":",
"d",
"=",
"[",
"v... | Put data to cach, if reached size value, it'll execute at once. | [
"Put",
"data",
"to",
"cach",
"if",
"reached",
"size",
"value",
"it",
"ll",
"execute",
"at",
"once",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/orm/__init__.py#L4931-L4949 |
7,010 | limodou/uliweb | uliweb/contrib/secretkey/__init__.py | get_key | def get_key(keyfile=None):
"""
Read the key content from secret_file
"""
keyfile = keyfile or application_path(settings.SECRETKEY.SECRET_FILE)
with file(keyfile, 'rb') as f:
return f.read() | python | def get_key(keyfile=None):
"""
Read the key content from secret_file
"""
keyfile = keyfile or application_path(settings.SECRETKEY.SECRET_FILE)
with file(keyfile, 'rb') as f:
return f.read() | [
"def",
"get_key",
"(",
"keyfile",
"=",
"None",
")",
":",
"keyfile",
"=",
"keyfile",
"or",
"application_path",
"(",
"settings",
".",
"SECRETKEY",
".",
"SECRET_FILE",
")",
"with",
"file",
"(",
"keyfile",
",",
"'rb'",
")",
"as",
"f",
":",
"return",
"f",
"... | Read the key content from secret_file | [
"Read",
"the",
"key",
"content",
"from",
"secret_file"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/contrib/secretkey/__init__.py#L34-L40 |
7,011 | limodou/uliweb | uliweb/contrib/secretkey/__init__.py | get_cipher_key | def get_cipher_key(keyfile=None):
"""
Create key which will be used in des, because des need 8bytes chars
"""
_key = get_key(keyfile)
_k = md5(_key).hexdigest()
key = xor(_k[:8], _k[8:16], _k[16:24], _k[24:])
return key | python | def get_cipher_key(keyfile=None):
"""
Create key which will be used in des, because des need 8bytes chars
"""
_key = get_key(keyfile)
_k = md5(_key).hexdigest()
key = xor(_k[:8], _k[8:16], _k[16:24], _k[24:])
return key | [
"def",
"get_cipher_key",
"(",
"keyfile",
"=",
"None",
")",
":",
"_key",
"=",
"get_key",
"(",
"keyfile",
")",
"_k",
"=",
"md5",
"(",
"_key",
")",
".",
"hexdigest",
"(",
")",
"key",
"=",
"xor",
"(",
"_k",
"[",
":",
"8",
"]",
",",
"_k",
"[",
"8",
... | Create key which will be used in des, because des need 8bytes chars | [
"Create",
"key",
"which",
"will",
"be",
"used",
"in",
"des",
"because",
"des",
"need",
"8bytes",
"chars"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/contrib/secretkey/__init__.py#L42-L49 |
7,012 | limodou/uliweb | uliweb/lib/werkzeug/contrib/cache.py | BaseCache.set_many | def set_many(self, mapping, timeout=None):
"""Sets multiple keys and values from a mapping.
:param mapping: a mapping with the keys/values to set.
:param timeout: the cache timeout for the key (if not specified,
it uses the default timeout).
"""
for key, ... | python | def set_many(self, mapping, timeout=None):
"""Sets multiple keys and values from a mapping.
:param mapping: a mapping with the keys/values to set.
:param timeout: the cache timeout for the key (if not specified,
it uses the default timeout).
"""
for key, ... | [
"def",
"set_many",
"(",
"self",
",",
"mapping",
",",
"timeout",
"=",
"None",
")",
":",
"for",
"key",
",",
"value",
"in",
"_items",
"(",
"mapping",
")",
":",
"self",
".",
"set",
"(",
"key",
",",
"value",
",",
"timeout",
")"
] | Sets multiple keys and values from a mapping.
:param mapping: a mapping with the keys/values to set.
:param timeout: the cache timeout for the key (if not specified,
it uses the default timeout). | [
"Sets",
"multiple",
"keys",
"and",
"values",
"from",
"a",
"mapping",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/contrib/cache.py#L166-L174 |
7,013 | limodou/uliweb | uliweb/lib/werkzeug/contrib/cache.py | BaseCache.dec | def dec(self, key, delta=1):
"""Decrements the value of a key by `delta`. If the key does
not yet exist it is initialized with `-delta`.
For supporting caches this is an atomic operation.
:param key: the key to increment.
:param delta: the delta to subtract.
"""
... | python | def dec(self, key, delta=1):
"""Decrements the value of a key by `delta`. If the key does
not yet exist it is initialized with `-delta`.
For supporting caches this is an atomic operation.
:param key: the key to increment.
:param delta: the delta to subtract.
"""
... | [
"def",
"dec",
"(",
"self",
",",
"key",
",",
"delta",
"=",
"1",
")",
":",
"self",
".",
"set",
"(",
"key",
",",
"(",
"self",
".",
"get",
"(",
"key",
")",
"or",
"0",
")",
"-",
"delta",
")"
] | Decrements the value of a key by `delta`. If the key does
not yet exist it is initialized with `-delta`.
For supporting caches this is an atomic operation.
:param key: the key to increment.
:param delta: the delta to subtract. | [
"Decrements",
"the",
"value",
"of",
"a",
"key",
"by",
"delta",
".",
"If",
"the",
"key",
"does",
"not",
"yet",
"exist",
"it",
"is",
"initialized",
"with",
"-",
"delta",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/contrib/cache.py#L202-L211 |
7,014 | limodou/uliweb | uliweb/lib/werkzeug/contrib/cache.py | MemcachedCache.import_preferred_memcache_lib | def import_preferred_memcache_lib(self, servers):
"""Returns an initialized memcache client. Used by the constructor."""
try:
import pylibmc
except ImportError:
pass
else:
return pylibmc.Client(servers)
try:
from google.appengine.... | python | def import_preferred_memcache_lib(self, servers):
"""Returns an initialized memcache client. Used by the constructor."""
try:
import pylibmc
except ImportError:
pass
else:
return pylibmc.Client(servers)
try:
from google.appengine.... | [
"def",
"import_preferred_memcache_lib",
"(",
"self",
",",
"servers",
")",
":",
"try",
":",
"import",
"pylibmc",
"except",
"ImportError",
":",
"pass",
"else",
":",
"return",
"pylibmc",
".",
"Client",
"(",
"servers",
")",
"try",
":",
"from",
"google",
".",
"... | Returns an initialized memcache client. Used by the constructor. | [
"Returns",
"an",
"initialized",
"memcache",
"client",
".",
"Used",
"by",
"the",
"constructor",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/contrib/cache.py#L420-L441 |
7,015 | limodou/uliweb | uliweb/lib/werkzeug/contrib/cache.py | RedisCache.dump_object | def dump_object(self, value):
"""Dumps an object into a string for redis. By default it serializes
integers as regular string and pickle dumps everything else.
"""
t = type(value)
if t is int or t is long:
return str(value)
return '!' + pickle.dumps(value) | python | def dump_object(self, value):
"""Dumps an object into a string for redis. By default it serializes
integers as regular string and pickle dumps everything else.
"""
t = type(value)
if t is int or t is long:
return str(value)
return '!' + pickle.dumps(value) | [
"def",
"dump_object",
"(",
"self",
",",
"value",
")",
":",
"t",
"=",
"type",
"(",
"value",
")",
"if",
"t",
"is",
"int",
"or",
"t",
"is",
"long",
":",
"return",
"str",
"(",
"value",
")",
"return",
"'!'",
"+",
"pickle",
".",
"dumps",
"(",
"value",
... | Dumps an object into a string for redis. By default it serializes
integers as regular string and pickle dumps everything else. | [
"Dumps",
"an",
"object",
"into",
"a",
"string",
"for",
"redis",
".",
"By",
"default",
"it",
"serializes",
"integers",
"as",
"regular",
"string",
"and",
"pickle",
"dumps",
"everything",
"else",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/contrib/cache.py#L491-L498 |
7,016 | limodou/uliweb | uliweb/utils/common.py | extract_dirs | def extract_dirs(mod, path, dst, verbose=False, exclude=None, exclude_ext=None, recursion=True, replace=True):
"""
mod name
path mod path
dst output directory
resursion True will extract all sub module of mod
"""
default_exclude = ['.svn', '_svn', '.git']
default_exclude_ext = ['.pyc', '... | python | def extract_dirs(mod, path, dst, verbose=False, exclude=None, exclude_ext=None, recursion=True, replace=True):
"""
mod name
path mod path
dst output directory
resursion True will extract all sub module of mod
"""
default_exclude = ['.svn', '_svn', '.git']
default_exclude_ext = ['.pyc', '... | [
"def",
"extract_dirs",
"(",
"mod",
",",
"path",
",",
"dst",
",",
"verbose",
"=",
"False",
",",
"exclude",
"=",
"None",
",",
"exclude_ext",
"=",
"None",
",",
"recursion",
"=",
"True",
",",
"replace",
"=",
"True",
")",
":",
"default_exclude",
"=",
"[",
... | mod name
path mod path
dst output directory
resursion True will extract all sub module of mod | [
"mod",
"name",
"path",
"mod",
"path",
"dst",
"output",
"directory",
"resursion",
"True",
"will",
"extract",
"all",
"sub",
"module",
"of",
"mod"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/utils/common.py#L110-L137 |
7,017 | limodou/uliweb | uliweb/utils/common.py | walk_dirs | def walk_dirs(path, include=None, include_ext=None, exclude=None,
exclude_ext=None, recursion=True, file_only=False,
use_default_pattern=True, patterns=None):
"""
path directory path
resursion True will extract all sub module of mod
"""
default_exclude = ['.svn', '_svn', '.git']
... | python | def walk_dirs(path, include=None, include_ext=None, exclude=None,
exclude_ext=None, recursion=True, file_only=False,
use_default_pattern=True, patterns=None):
"""
path directory path
resursion True will extract all sub module of mod
"""
default_exclude = ['.svn', '_svn', '.git']
... | [
"def",
"walk_dirs",
"(",
"path",
",",
"include",
"=",
"None",
",",
"include_ext",
"=",
"None",
",",
"exclude",
"=",
"None",
",",
"exclude_ext",
"=",
"None",
",",
"recursion",
"=",
"True",
",",
"file_only",
"=",
"False",
",",
"use_default_pattern",
"=",
"... | path directory path
resursion True will extract all sub module of mod | [
"path",
"directory",
"path",
"resursion",
"True",
"will",
"extract",
"all",
"sub",
"module",
"of",
"mod"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/utils/common.py#L147-L187 |
7,018 | limodou/uliweb | uliweb/utils/common.py | camel_to_ | def camel_to_(s):
"""
Convert CamelCase to camel_case
"""
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', s)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() | python | def camel_to_(s):
"""
Convert CamelCase to camel_case
"""
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', s)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() | [
"def",
"camel_to_",
"(",
"s",
")",
":",
"s1",
"=",
"re",
".",
"sub",
"(",
"'(.)([A-Z][a-z]+)'",
",",
"r'\\1_\\2'",
",",
"s",
")",
"return",
"re",
".",
"sub",
"(",
"'([a-z0-9])([A-Z])'",
",",
"r'\\1_\\2'",
",",
"s1",
")",
".",
"lower",
"(",
")"
] | Convert CamelCase to camel_case | [
"Convert",
"CamelCase",
"to",
"camel_case"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/utils/common.py#L605-L610 |
7,019 | limodou/uliweb | uliweb/utils/common.py | application_path | def application_path(path):
"""
Join application project_dir and path
"""
from uliweb import application
return os.path.join(application.project_dir, path) | python | def application_path(path):
"""
Join application project_dir and path
"""
from uliweb import application
return os.path.join(application.project_dir, path) | [
"def",
"application_path",
"(",
"path",
")",
":",
"from",
"uliweb",
"import",
"application",
"return",
"os",
".",
"path",
".",
"join",
"(",
"application",
".",
"project_dir",
",",
"path",
")"
] | Join application project_dir and path | [
"Join",
"application",
"project_dir",
"and",
"path"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/utils/common.py#L612-L617 |
7,020 | limodou/uliweb | uliweb/utils/common.py | get_uuid | def get_uuid(type=4):
"""
Get uuid value
"""
import uuid
name = 'uuid'+str(type)
u = getattr(uuid, name)
return u().hex | python | def get_uuid(type=4):
"""
Get uuid value
"""
import uuid
name = 'uuid'+str(type)
u = getattr(uuid, name)
return u().hex | [
"def",
"get_uuid",
"(",
"type",
"=",
"4",
")",
":",
"import",
"uuid",
"name",
"=",
"'uuid'",
"+",
"str",
"(",
"type",
")",
"u",
"=",
"getattr",
"(",
"uuid",
",",
"name",
")",
"return",
"u",
"(",
")",
".",
"hex"
] | Get uuid value | [
"Get",
"uuid",
"value"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/utils/common.py#L619-L627 |
7,021 | limodou/uliweb | uliweb/utils/common.py | request_url | def request_url(req=None):
"""
Get full url of a request
"""
from uliweb import request
r = req or request
if request:
if r.query_string:
return r.path + '?' + r.query_string
else:
return r.path
else:
return '' | python | def request_url(req=None):
"""
Get full url of a request
"""
from uliweb import request
r = req or request
if request:
if r.query_string:
return r.path + '?' + r.query_string
else:
return r.path
else:
return '' | [
"def",
"request_url",
"(",
"req",
"=",
"None",
")",
":",
"from",
"uliweb",
"import",
"request",
"r",
"=",
"req",
"or",
"request",
"if",
"request",
":",
"if",
"r",
".",
"query_string",
":",
"return",
"r",
".",
"path",
"+",
"'?'",
"+",
"r",
".",
"que... | Get full url of a request | [
"Get",
"full",
"url",
"of",
"a",
"request"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/utils/common.py#L658-L671 |
7,022 | limodou/uliweb | uliweb/utils/common.py | compare_dict | def compare_dict(da, db):
"""
Compare differencs from two dicts
"""
sa = set(da.items())
sb = set(db.items())
diff = sa & sb
return dict(sa - diff), dict(sb - diff) | python | def compare_dict(da, db):
"""
Compare differencs from two dicts
"""
sa = set(da.items())
sb = set(db.items())
diff = sa & sb
return dict(sa - diff), dict(sb - diff) | [
"def",
"compare_dict",
"(",
"da",
",",
"db",
")",
":",
"sa",
"=",
"set",
"(",
"da",
".",
"items",
"(",
")",
")",
"sb",
"=",
"set",
"(",
"db",
".",
"items",
"(",
")",
")",
"diff",
"=",
"sa",
"&",
"sb",
"return",
"dict",
"(",
"sa",
"-",
"diff... | Compare differencs from two dicts | [
"Compare",
"differencs",
"from",
"two",
"dicts"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/utils/common.py#L711-L719 |
7,023 | limodou/uliweb | uliweb/utils/common.py | get_configrable_object | def get_configrable_object(key, section, cls=None):
"""
if obj is a class, then check if the class is subclass of cls
or it should be object path, and it'll be imported by import_attr
"""
from uliweb import UliwebError, settings
import inspect
if inspect.isclass(key) and cls and issubclass(... | python | def get_configrable_object(key, section, cls=None):
"""
if obj is a class, then check if the class is subclass of cls
or it should be object path, and it'll be imported by import_attr
"""
from uliweb import UliwebError, settings
import inspect
if inspect.isclass(key) and cls and issubclass(... | [
"def",
"get_configrable_object",
"(",
"key",
",",
"section",
",",
"cls",
"=",
"None",
")",
":",
"from",
"uliweb",
"import",
"UliwebError",
",",
"settings",
"import",
"inspect",
"if",
"inspect",
".",
"isclass",
"(",
"key",
")",
"and",
"cls",
"and",
"issubcl... | if obj is a class, then check if the class is subclass of cls
or it should be object path, and it'll be imported by import_attr | [
"if",
"obj",
"is",
"a",
"class",
"then",
"check",
"if",
"the",
"class",
"is",
"subclass",
"of",
"cls",
"or",
"it",
"should",
"be",
"object",
"path",
"and",
"it",
"ll",
"be",
"imported",
"by",
"import_attr"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/utils/common.py#L824-L842 |
7,024 | limodou/uliweb | uliweb/utils/common.py | convert_bytes | def convert_bytes(n):
"""
Convert a size number to 'K', 'M', .etc
"""
symbols = ('K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
prefix = {}
for i, s in enumerate(symbols):
prefix[s] = 1 << (i + 1) * 10
for s in reversed(symbols):
if n >= prefix[s]:
value = float(n) / pre... | python | def convert_bytes(n):
"""
Convert a size number to 'K', 'M', .etc
"""
symbols = ('K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
prefix = {}
for i, s in enumerate(symbols):
prefix[s] = 1 << (i + 1) * 10
for s in reversed(symbols):
if n >= prefix[s]:
value = float(n) / pre... | [
"def",
"convert_bytes",
"(",
"n",
")",
":",
"symbols",
"=",
"(",
"'K'",
",",
"'M'",
",",
"'G'",
",",
"'T'",
",",
"'P'",
",",
"'E'",
",",
"'Z'",
",",
"'Y'",
")",
"prefix",
"=",
"{",
"}",
"for",
"i",
",",
"s",
"in",
"enumerate",
"(",
"symbols",
... | Convert a size number to 'K', 'M', .etc | [
"Convert",
"a",
"size",
"number",
"to",
"K",
"M",
".",
"etc"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/utils/common.py#L868-L880 |
7,025 | limodou/uliweb | uliweb/contrib/template/__init__.py | init_static_combine | def init_static_combine():
"""
Process static combine, create md5 key according each static filename
"""
from uliweb import settings
from hashlib import md5
import os
d = {}
if settings.get_var('STATIC_COMBINE_CONFIG/enable', False):
for k, v in settings.get('STATI... | python | def init_static_combine():
"""
Process static combine, create md5 key according each static filename
"""
from uliweb import settings
from hashlib import md5
import os
d = {}
if settings.get_var('STATIC_COMBINE_CONFIG/enable', False):
for k, v in settings.get('STATI... | [
"def",
"init_static_combine",
"(",
")",
":",
"from",
"uliweb",
"import",
"settings",
"from",
"hashlib",
"import",
"md5",
"import",
"os",
"d",
"=",
"{",
"}",
"if",
"settings",
".",
"get_var",
"(",
"'STATIC_COMBINE_CONFIG/enable'",
",",
"False",
")",
":",
"for... | Process static combine, create md5 key according each static filename | [
"Process",
"static",
"combine",
"create",
"md5",
"key",
"according",
"each",
"static",
"filename"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/contrib/template/__init__.py#L9-L23 |
7,026 | limodou/uliweb | uliweb/contrib/csrf/__init__.py | csrf_token | def csrf_token():
"""
Get csrf token or create new one
"""
from uliweb import request, settings
from uliweb.utils.common import safe_str
v = {}
token_name = settings.CSRF.cookie_token_name
if not request.session.deleted and request.session.get(token_name):
v = request.sessio... | python | def csrf_token():
"""
Get csrf token or create new one
"""
from uliweb import request, settings
from uliweb.utils.common import safe_str
v = {}
token_name = settings.CSRF.cookie_token_name
if not request.session.deleted and request.session.get(token_name):
v = request.sessio... | [
"def",
"csrf_token",
"(",
")",
":",
"from",
"uliweb",
"import",
"request",
",",
"settings",
"from",
"uliweb",
".",
"utils",
".",
"common",
"import",
"safe_str",
"v",
"=",
"{",
"}",
"token_name",
"=",
"settings",
".",
"CSRF",
".",
"cookie_token_name",
"if",... | Get csrf token or create new one | [
"Get",
"csrf",
"token",
"or",
"create",
"new",
"one"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/contrib/csrf/__init__.py#L5-L29 |
7,027 | limodou/uliweb | uliweb/lib/werkzeug/contrib/wrappers.py | JSONRequestMixin.json | def json(self):
"""Get the result of simplejson.loads if possible."""
if 'json' not in self.environ.get('CONTENT_TYPE', ''):
raise BadRequest('Not a JSON request')
try:
return loads(self.data)
except Exception:
raise BadRequest('Unable to read JSON req... | python | def json(self):
"""Get the result of simplejson.loads if possible."""
if 'json' not in self.environ.get('CONTENT_TYPE', ''):
raise BadRequest('Not a JSON request')
try:
return loads(self.data)
except Exception:
raise BadRequest('Unable to read JSON req... | [
"def",
"json",
"(",
"self",
")",
":",
"if",
"'json'",
"not",
"in",
"self",
".",
"environ",
".",
"get",
"(",
"'CONTENT_TYPE'",
",",
"''",
")",
":",
"raise",
"BadRequest",
"(",
"'Not a JSON request'",
")",
"try",
":",
"return",
"loads",
"(",
"self",
".",... | Get the result of simplejson.loads if possible. | [
"Get",
"the",
"result",
"of",
"simplejson",
".",
"loads",
"if",
"possible",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/contrib/wrappers.py#L53-L60 |
7,028 | limodou/uliweb | uliweb/lib/werkzeug/contrib/wrappers.py | ProtobufRequestMixin.parse_protobuf | def parse_protobuf(self, proto_type):
"""Parse the data into an instance of proto_type."""
if 'protobuf' not in self.environ.get('CONTENT_TYPE', ''):
raise BadRequest('Not a Protobuf request')
obj = proto_type()
try:
obj.ParseFromString(self.data)
except ... | python | def parse_protobuf(self, proto_type):
"""Parse the data into an instance of proto_type."""
if 'protobuf' not in self.environ.get('CONTENT_TYPE', ''):
raise BadRequest('Not a Protobuf request')
obj = proto_type()
try:
obj.ParseFromString(self.data)
except ... | [
"def",
"parse_protobuf",
"(",
"self",
",",
"proto_type",
")",
":",
"if",
"'protobuf'",
"not",
"in",
"self",
".",
"environ",
".",
"get",
"(",
"'CONTENT_TYPE'",
",",
"''",
")",
":",
"raise",
"BadRequest",
"(",
"'Not a Protobuf request'",
")",
"obj",
"=",
"pr... | Parse the data into an instance of proto_type. | [
"Parse",
"the",
"data",
"into",
"an",
"instance",
"of",
"proto_type",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/contrib/wrappers.py#L79-L94 |
7,029 | limodou/uliweb | uliweb/lib/werkzeug/contrib/wrappers.py | DynamicCharsetRequestMixin.charset | def charset(self):
"""The charset from the content type."""
header = self.environ.get('CONTENT_TYPE')
if header:
ct, options = parse_options_header(header)
charset = options.get('charset')
if charset:
if is_known_charset(charset):
... | python | def charset(self):
"""The charset from the content type."""
header = self.environ.get('CONTENT_TYPE')
if header:
ct, options = parse_options_header(header)
charset = options.get('charset')
if charset:
if is_known_charset(charset):
... | [
"def",
"charset",
"(",
"self",
")",
":",
"header",
"=",
"self",
".",
"environ",
".",
"get",
"(",
"'CONTENT_TYPE'",
")",
"if",
"header",
":",
"ct",
",",
"options",
"=",
"parse_options_header",
"(",
"header",
")",
"charset",
"=",
"options",
".",
"get",
"... | The charset from the content type. | [
"The",
"charset",
"from",
"the",
"content",
"type",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/contrib/wrappers.py#L222-L232 |
7,030 | limodou/uliweb | uliweb/core/template.py | utf8 | def utf8(value):
"""Converts a string argument to a byte string.
If the argument is already a byte string or None, it is returned unchanged.
Otherwise it must be a unicode string and is encoded as utf8.
"""
if isinstance(value, _UTF8_TYPES):
return value
elif isinstance(value, u... | python | def utf8(value):
"""Converts a string argument to a byte string.
If the argument is already a byte string or None, it is returned unchanged.
Otherwise it must be a unicode string and is encoded as utf8.
"""
if isinstance(value, _UTF8_TYPES):
return value
elif isinstance(value, u... | [
"def",
"utf8",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"_UTF8_TYPES",
")",
":",
"return",
"value",
"elif",
"isinstance",
"(",
"value",
",",
"unicode_type",
")",
":",
"return",
"value",
".",
"encode",
"(",
"\"utf-8\"",
")",
"else",
... | Converts a string argument to a byte string.
If the argument is already a byte string or None, it is returned unchanged.
Otherwise it must be a unicode string and is encoded as utf8. | [
"Converts",
"a",
"string",
"argument",
"to",
"a",
"byte",
"string",
".",
"If",
"the",
"argument",
"is",
"already",
"a",
"byte",
"string",
"or",
"None",
"it",
"is",
"returned",
"unchanged",
".",
"Otherwise",
"it",
"must",
"be",
"a",
"unicode",
"string",
"... | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/core/template.py#L249-L260 |
7,031 | limodou/uliweb | uliweb/core/template.py | to_basestring | def to_basestring(value):
"""Converts a string argument to a subclass of basestring.
In python2, byte and unicode strings are mostly interchangeable,
so functions that deal with a user-supplied argument in combination
with ascii string constants can use either and should return the type
the u... | python | def to_basestring(value):
"""Converts a string argument to a subclass of basestring.
In python2, byte and unicode strings are mostly interchangeable,
so functions that deal with a user-supplied argument in combination
with ascii string constants can use either and should return the type
the u... | [
"def",
"to_basestring",
"(",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"'None'",
"if",
"isinstance",
"(",
"value",
",",
"_BASESTRING_TYPES",
")",
":",
"return",
"value",
"elif",
"isinstance",
"(",
"value",
",",
"unicode_type",
")",
":"... | Converts a string argument to a subclass of basestring.
In python2, byte and unicode strings are mostly interchangeable,
so functions that deal with a user-supplied argument in combination
with ascii string constants can use either and should return the type
the user supplied. In python3, the two... | [
"Converts",
"a",
"string",
"argument",
"to",
"a",
"subclass",
"of",
"basestring",
".",
"In",
"python2",
"byte",
"and",
"unicode",
"strings",
"are",
"mostly",
"interchangeable",
"so",
"functions",
"that",
"deal",
"with",
"a",
"user",
"-",
"supplied",
"argument"... | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/core/template.py#L293-L309 |
7,032 | limodou/uliweb | uliweb/core/template.py | LRUTmplatesCacheDict.clear | def clear(self):
"""
Clears the dict.
"""
self.__values.clear()
self.__access_keys = []
self.__modified_times.clear() | python | def clear(self):
"""
Clears the dict.
"""
self.__values.clear()
self.__access_keys = []
self.__modified_times.clear() | [
"def",
"clear",
"(",
"self",
")",
":",
"self",
".",
"__values",
".",
"clear",
"(",
")",
"self",
".",
"__access_keys",
"=",
"[",
"]",
"self",
".",
"__modified_times",
".",
"clear",
"(",
")"
] | Clears the dict. | [
"Clears",
"the",
"dict",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/core/template.py#L677-L683 |
7,033 | limodou/uliweb | uliweb/core/template.py | LRUTmplatesCacheDict.has | def has(self, key, mtime=None):
"""
This method should almost NEVER be used. The reason is that between the time
has_key is called, and the key is accessed, the key might vanish.
"""
v = self.__values.get(key, None)
if not v:
return False
if ... | python | def has(self, key, mtime=None):
"""
This method should almost NEVER be used. The reason is that between the time
has_key is called, and the key is accessed, the key might vanish.
"""
v = self.__values.get(key, None)
if not v:
return False
if ... | [
"def",
"has",
"(",
"self",
",",
"key",
",",
"mtime",
"=",
"None",
")",
":",
"v",
"=",
"self",
".",
"__values",
".",
"get",
"(",
"key",
",",
"None",
")",
"if",
"not",
"v",
":",
"return",
"False",
"if",
"self",
".",
"check_modified_time",
":",
"mti... | This method should almost NEVER be used. The reason is that between the time
has_key is called, and the key is accessed, the key might vanish. | [
"This",
"method",
"should",
"almost",
"NEVER",
"be",
"used",
".",
"The",
"reason",
"is",
"that",
"between",
"the",
"time",
"has_key",
"is",
"called",
"and",
"the",
"key",
"is",
"accessed",
"the",
"key",
"might",
"vanish",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/core/template.py#L694-L708 |
7,034 | limodou/uliweb | uliweb/core/template.py | Loader.reset | def reset(self):
"""Resets the cache of compiled templates."""
with self.lock:
if self.cache:
if self.use_tmp:
shutil.rmtree(self.tmp_dir, ignore_errors=True)
else:
self.templates = {} | python | def reset(self):
"""Resets the cache of compiled templates."""
with self.lock:
if self.cache:
if self.use_tmp:
shutil.rmtree(self.tmp_dir, ignore_errors=True)
else:
self.templates = {} | [
"def",
"reset",
"(",
"self",
")",
":",
"with",
"self",
".",
"lock",
":",
"if",
"self",
".",
"cache",
":",
"if",
"self",
".",
"use_tmp",
":",
"shutil",
".",
"rmtree",
"(",
"self",
".",
"tmp_dir",
",",
"ignore_errors",
"=",
"True",
")",
"else",
":",
... | Resets the cache of compiled templates. | [
"Resets",
"the",
"cache",
"of",
"compiled",
"templates",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/core/template.py#L796-L803 |
7,035 | limodou/uliweb | uliweb/contrib/rbac/rbac.py | has_role | def has_role(user, *roles, **kwargs):
"""
Judge is the user belongs to the role, and if does, then return the role object
if not then return False. kwargs will be passed to role_func.
"""
Role = get_model('role')
if isinstance(user, (unicode, str)):
User = get_model('user')
... | python | def has_role(user, *roles, **kwargs):
"""
Judge is the user belongs to the role, and if does, then return the role object
if not then return False. kwargs will be passed to role_func.
"""
Role = get_model('role')
if isinstance(user, (unicode, str)):
User = get_model('user')
... | [
"def",
"has_role",
"(",
"user",
",",
"*",
"roles",
",",
"*",
"*",
"kwargs",
")",
":",
"Role",
"=",
"get_model",
"(",
"'role'",
")",
"if",
"isinstance",
"(",
"user",
",",
"(",
"unicode",
",",
"str",
")",
")",
":",
"User",
"=",
"get_model",
"(",
"'... | Judge is the user belongs to the role, and if does, then return the role object
if not then return False. kwargs will be passed to role_func. | [
"Judge",
"is",
"the",
"user",
"belongs",
"to",
"the",
"role",
"and",
"if",
"does",
"then",
"return",
"the",
"role",
"object",
"if",
"not",
"then",
"return",
"False",
".",
"kwargs",
"will",
"be",
"passed",
"to",
"role_func",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/contrib/rbac/rbac.py#L42-L78 |
7,036 | limodou/uliweb | uliweb/contrib/rbac/rbac.py | has_permission | def has_permission(user, *permissions, **role_kwargs):
"""
Judge if an user has permission, and if it does return role object, and if it doesn't
return False. role_kwargs will be passed to role functions.
With role object, you can use role.relation to get Role_Perm_Rel object.
"""
Role = g... | python | def has_permission(user, *permissions, **role_kwargs):
"""
Judge if an user has permission, and if it does return role object, and if it doesn't
return False. role_kwargs will be passed to role functions.
With role object, you can use role.relation to get Role_Perm_Rel object.
"""
Role = g... | [
"def",
"has_permission",
"(",
"user",
",",
"*",
"permissions",
",",
"*",
"*",
"role_kwargs",
")",
":",
"Role",
"=",
"get_model",
"(",
"'role'",
")",
"Perm",
"=",
"get_model",
"(",
"'permission'",
")",
"if",
"isinstance",
"(",
"user",
",",
"(",
"unicode",... | Judge if an user has permission, and if it does return role object, and if it doesn't
return False. role_kwargs will be passed to role functions.
With role object, you can use role.relation to get Role_Perm_Rel object. | [
"Judge",
"if",
"an",
"user",
"has",
"permission",
"and",
"if",
"it",
"does",
"return",
"role",
"object",
"and",
"if",
"it",
"doesn",
"t",
"return",
"False",
".",
"role_kwargs",
"will",
"be",
"passed",
"to",
"role",
"functions",
".",
"With",
"role",
"obje... | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/contrib/rbac/rbac.py#L80-L101 |
7,037 | limodou/uliweb | uliweb/lib/werkzeug/serving.py | load_ssl_context | def load_ssl_context(cert_file, pkey_file):
"""Loads an SSL context from a certificate and private key file."""
from OpenSSL import SSL
ctx = SSL.Context(SSL.SSLv23_METHOD)
ctx.use_certificate_file(cert_file)
ctx.use_privatekey_file(pkey_file)
return ctx | python | def load_ssl_context(cert_file, pkey_file):
"""Loads an SSL context from a certificate and private key file."""
from OpenSSL import SSL
ctx = SSL.Context(SSL.SSLv23_METHOD)
ctx.use_certificate_file(cert_file)
ctx.use_privatekey_file(pkey_file)
return ctx | [
"def",
"load_ssl_context",
"(",
"cert_file",
",",
"pkey_file",
")",
":",
"from",
"OpenSSL",
"import",
"SSL",
"ctx",
"=",
"SSL",
".",
"Context",
"(",
"SSL",
".",
"SSLv23_METHOD",
")",
"ctx",
".",
"use_certificate_file",
"(",
"cert_file",
")",
"ctx",
".",
"u... | Loads an SSL context from a certificate and private key file. | [
"Loads",
"an",
"SSL",
"context",
"from",
"a",
"certificate",
"and",
"private",
"key",
"file",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/serving.py#L344-L350 |
7,038 | limodou/uliweb | uliweb/lib/werkzeug/serving.py | select_ip_version | def select_ip_version(host, port):
"""Returns AF_INET4 or AF_INET6 depending on where to connect to."""
# disabled due to problems with current ipv6 implementations
# and various operating systems. Probably this code also is
# not supposed to work, but I can't come up with any other
# ways to imple... | python | def select_ip_version(host, port):
"""Returns AF_INET4 or AF_INET6 depending on where to connect to."""
# disabled due to problems with current ipv6 implementations
# and various operating systems. Probably this code also is
# not supposed to work, but I can't come up with any other
# ways to imple... | [
"def",
"select_ip_version",
"(",
"host",
",",
"port",
")",
":",
"# disabled due to problems with current ipv6 implementations",
"# and various operating systems. Probably this code also is",
"# not supposed to work, but I can't come up with any other",
"# ways to implement this.",
"##try:",... | Returns AF_INET4 or AF_INET6 depending on where to connect to. | [
"Returns",
"AF_INET4",
"or",
"AF_INET6",
"depending",
"on",
"where",
"to",
"connect",
"to",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/serving.py#L380-L396 |
7,039 | limodou/uliweb | uliweb/lib/werkzeug/serving.py | make_server | def make_server(host, port, app=None, threaded=False, processes=1,
request_handler=None, passthrough_errors=False,
ssl_context=None):
"""Create a new server instance that is either threaded, or forks
or just processes one request after another.
"""
if threaded and process... | python | def make_server(host, port, app=None, threaded=False, processes=1,
request_handler=None, passthrough_errors=False,
ssl_context=None):
"""Create a new server instance that is either threaded, or forks
or just processes one request after another.
"""
if threaded and process... | [
"def",
"make_server",
"(",
"host",
",",
"port",
",",
"app",
"=",
"None",
",",
"threaded",
"=",
"False",
",",
"processes",
"=",
"1",
",",
"request_handler",
"=",
"None",
",",
"passthrough_errors",
"=",
"False",
",",
"ssl_context",
"=",
"None",
")",
":",
... | Create a new server instance that is either threaded, or forks
or just processes one request after another. | [
"Create",
"a",
"new",
"server",
"instance",
"that",
"is",
"either",
"threaded",
"or",
"forks",
"or",
"just",
"processes",
"one",
"request",
"after",
"another",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/serving.py#L469-L486 |
7,040 | limodou/uliweb | uliweb/lib/werkzeug/serving.py | _reloader_stat_loop | def _reloader_stat_loop(extra_files=None, interval=1):
"""When this function is run from the main thread, it will force other
threads to exit when any modules currently loaded change.
Copyright notice. This function is based on the autoreload.py from
the CherryPy trac which originated from WSGIKit whi... | python | def _reloader_stat_loop(extra_files=None, interval=1):
"""When this function is run from the main thread, it will force other
threads to exit when any modules currently loaded change.
Copyright notice. This function is based on the autoreload.py from
the CherryPy trac which originated from WSGIKit whi... | [
"def",
"_reloader_stat_loop",
"(",
"extra_files",
"=",
"None",
",",
"interval",
"=",
"1",
")",
":",
"from",
"itertools",
"import",
"chain",
"mtimes",
"=",
"{",
"}",
"while",
"1",
":",
"for",
"filename",
"in",
"chain",
"(",
"_iter_module_files",
"(",
")",
... | When this function is run from the main thread, it will force other
threads to exit when any modules currently loaded change.
Copyright notice. This function is based on the autoreload.py from
the CherryPy trac which originated from WSGIKit which is now dead.
:param extra_files: a list of additional ... | [
"When",
"this",
"function",
"is",
"run",
"from",
"the",
"main",
"thread",
"it",
"will",
"force",
"other",
"threads",
"to",
"exit",
"when",
"any",
"modules",
"currently",
"loaded",
"change",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/serving.py#L507-L532 |
7,041 | limodou/uliweb | uliweb/lib/werkzeug/serving.py | run_simple | def run_simple(hostname, port, application, use_reloader=False,
use_debugger=False, use_evalex=True,
extra_files=None, reloader_interval=1, threaded=False,
processes=1, request_handler=None, static_files=None,
passthrough_errors=False, ssl_context=None):
"... | python | def run_simple(hostname, port, application, use_reloader=False,
use_debugger=False, use_evalex=True,
extra_files=None, reloader_interval=1, threaded=False,
processes=1, request_handler=None, static_files=None,
passthrough_errors=False, ssl_context=None):
"... | [
"def",
"run_simple",
"(",
"hostname",
",",
"port",
",",
"application",
",",
"use_reloader",
"=",
"False",
",",
"use_debugger",
"=",
"False",
",",
"use_evalex",
"=",
"True",
",",
"extra_files",
"=",
"None",
",",
"reloader_interval",
"=",
"1",
",",
"threaded",... | Start an application using wsgiref and with an optional reloader. This
wraps `wsgiref` to fix the wrong default reporting of the multithreaded
WSGI variable and adds optional multithreading and fork support.
This function has a command-line interface too::
python -m werkzeug.serving --help
.... | [
"Start",
"an",
"application",
"using",
"wsgiref",
"and",
"with",
"an",
"optional",
"reloader",
".",
"This",
"wraps",
"wsgiref",
"to",
"fix",
"the",
"wrong",
"default",
"reporting",
"of",
"the",
"multithreaded",
"WSGI",
"variable",
"and",
"adds",
"optional",
"m... | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/serving.py#L626-L714 |
7,042 | limodou/uliweb | uliweb/core/html.py | to_attrs | def to_attrs(args, nocreate_if_none=['id', 'for', 'class']):
"""
Make python dict to k="v" format
"""
if not args:
return ''
s = ['']
for k, v in sorted(args.items()):
k = u_str(k)
v = u_str(v)
if k.startswith('_'):
k = k[1:]
if v is None:
... | python | def to_attrs(args, nocreate_if_none=['id', 'for', 'class']):
"""
Make python dict to k="v" format
"""
if not args:
return ''
s = ['']
for k, v in sorted(args.items()):
k = u_str(k)
v = u_str(v)
if k.startswith('_'):
k = k[1:]
if v is None:
... | [
"def",
"to_attrs",
"(",
"args",
",",
"nocreate_if_none",
"=",
"[",
"'id'",
",",
"'for'",
",",
"'class'",
"]",
")",
":",
"if",
"not",
"args",
":",
"return",
"''",
"s",
"=",
"[",
"''",
"]",
"for",
"k",
",",
"v",
"in",
"sorted",
"(",
"args",
".",
... | Make python dict to k="v" format | [
"Make",
"python",
"dict",
"to",
"k",
"=",
"v",
"format"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/core/html.py#L24-L46 |
7,043 | limodou/uliweb | uliweb/i18n/pygettext.py | _get_modpkg_path | def _get_modpkg_path(dotted_name, pathlist=None):
"""Get the filesystem path for a module or a package.
Return the file system path to a file for a module, and to a directory for
a package. Return None if the name is not found, or is a builtin or
extension module.
"""
# split off top-most name
... | python | def _get_modpkg_path(dotted_name, pathlist=None):
"""Get the filesystem path for a module or a package.
Return the file system path to a file for a module, and to a directory for
a package. Return None if the name is not found, or is a builtin or
extension module.
"""
# split off top-most name
... | [
"def",
"_get_modpkg_path",
"(",
"dotted_name",
",",
"pathlist",
"=",
"None",
")",
":",
"# split off top-most name",
"parts",
"=",
"dotted_name",
".",
"split",
"(",
"'.'",
",",
"1",
")",
"if",
"len",
"(",
"parts",
")",
">",
"1",
":",
"# we have a dotted path,... | Get the filesystem path for a module or a package.
Return the file system path to a file for a module, and to a directory for
a package. Return None if the name is not found, or is a builtin or
extension module. | [
"Get",
"the",
"filesystem",
"path",
"for",
"a",
"module",
"or",
"a",
"package",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/i18n/pygettext.py#L314-L350 |
7,044 | limodou/uliweb | uliweb/i18n/pygettext.py | getFilesForName | def getFilesForName(name):
"""Get a list of module files for a filename, a module or package name,
or a directory.
"""
if not os.path.exists(name):
# check for glob chars
if containsAny(name, "*?[]"):
files = glob.glob(name)
list = []
for file in files... | python | def getFilesForName(name):
"""Get a list of module files for a filename, a module or package name,
or a directory.
"""
if not os.path.exists(name):
# check for glob chars
if containsAny(name, "*?[]"):
files = glob.glob(name)
list = []
for file in files... | [
"def",
"getFilesForName",
"(",
"name",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"name",
")",
":",
"# check for glob chars",
"if",
"containsAny",
"(",
"name",
",",
"\"*?[]\"",
")",
":",
"files",
"=",
"glob",
".",
"glob",
"(",
"name"... | Get a list of module files for a filename, a module or package name,
or a directory. | [
"Get",
"a",
"list",
"of",
"module",
"files",
"for",
"a",
"filename",
"a",
"module",
"or",
"package",
"name",
"or",
"a",
"directory",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/i18n/pygettext.py#L353-L380 |
7,045 | limodou/uliweb | uliweb/lib/werkzeug/utils.py | unescape | def unescape(s):
"""The reverse function of `escape`. This unescapes all the HTML
entities, not only the XML entities inserted by `escape`.
:param s: the string to unescape.
"""
def handle_match(m):
name = m.group(1)
if name in HTMLBuilder._entities:
return unichr(HTMLB... | python | def unescape(s):
"""The reverse function of `escape`. This unescapes all the HTML
entities, not only the XML entities inserted by `escape`.
:param s: the string to unescape.
"""
def handle_match(m):
name = m.group(1)
if name in HTMLBuilder._entities:
return unichr(HTMLB... | [
"def",
"unescape",
"(",
"s",
")",
":",
"def",
"handle_match",
"(",
"m",
")",
":",
"name",
"=",
"m",
".",
"group",
"(",
"1",
")",
"if",
"name",
"in",
"HTMLBuilder",
".",
"_entities",
":",
"return",
"unichr",
"(",
"HTMLBuilder",
".",
"_entities",
"[",
... | The reverse function of `escape`. This unescapes all the HTML
entities, not only the XML entities inserted by `escape`.
:param s: the string to unescape. | [
"The",
"reverse",
"function",
"of",
"escape",
".",
"This",
"unescapes",
"all",
"the",
"HTML",
"entities",
"not",
"only",
"the",
"XML",
"entities",
"inserted",
"by",
"escape",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/utils.py#L317-L335 |
7,046 | limodou/uliweb | uliweb/lib/werkzeug/utils.py | append_slash_redirect | def append_slash_redirect(environ, code=301):
"""Redirect to the same URL but with a slash appended. The behavior
of this function is undefined if the path ends with a slash already.
:param environ: the WSGI environment for the request that triggers
the redirect.
:param code: the s... | python | def append_slash_redirect(environ, code=301):
"""Redirect to the same URL but with a slash appended. The behavior
of this function is undefined if the path ends with a slash already.
:param environ: the WSGI environment for the request that triggers
the redirect.
:param code: the s... | [
"def",
"append_slash_redirect",
"(",
"environ",
",",
"code",
"=",
"301",
")",
":",
"new_path",
"=",
"environ",
"[",
"'PATH_INFO'",
"]",
".",
"strip",
"(",
"'/'",
")",
"+",
"'/'",
"query_string",
"=",
"environ",
".",
"get",
"(",
"'QUERY_STRING'",
")",
"if... | Redirect to the same URL but with a slash appended. The behavior
of this function is undefined if the path ends with a slash already.
:param environ: the WSGI environment for the request that triggers
the redirect.
:param code: the status code for the redirect. | [
"Redirect",
"to",
"the",
"same",
"URL",
"but",
"with",
"a",
"slash",
"appended",
".",
"The",
"behavior",
"of",
"this",
"function",
"is",
"undefined",
"if",
"the",
"path",
"ends",
"with",
"a",
"slash",
"already",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/utils.py#L368-L380 |
7,047 | limodou/uliweb | uliweb/i18n/po_merge.py | parse_translation | def parse_translation(f, lineno):
"""Read a single translation entry from the file F and return a
tuple with the comments, msgid and msgstr. The comments is returned
as a list of lines which do not end in new-lines. The msgid and
msgstr are strings, possibly with embedded newlines"""
line = f... | python | def parse_translation(f, lineno):
"""Read a single translation entry from the file F and return a
tuple with the comments, msgid and msgstr. The comments is returned
as a list of lines which do not end in new-lines. The msgid and
msgstr are strings, possibly with embedded newlines"""
line = f... | [
"def",
"parse_translation",
"(",
"f",
",",
"lineno",
")",
":",
"line",
"=",
"f",
".",
"readline",
"(",
")",
"def",
"get_line",
"(",
"f",
",",
"line",
",",
"need_keys",
",",
"lineno",
",",
"default",
"=",
"'\"\"'",
")",
":",
"line",
"=",
"line",
"."... | Read a single translation entry from the file F and return a
tuple with the comments, msgid and msgstr. The comments is returned
as a list of lines which do not end in new-lines. The msgid and
msgstr are strings, possibly with embedded newlines | [
"Read",
"a",
"single",
"translation",
"entry",
"from",
"the",
"file",
"F",
"and",
"return",
"a",
"tuple",
"with",
"the",
"comments",
"msgid",
"and",
"msgstr",
".",
"The",
"comments",
"is",
"returned",
"as",
"a",
"list",
"of",
"lines",
"which",
"do",
"not... | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/i18n/po_merge.py#L5-L59 |
7,048 | limodou/uliweb | uliweb/contrib/form/__init__.py | get_form | def get_form(formcls):
"""
get form class according form class path or form class object
"""
from uliweb.form import Form
import inspect
if inspect.isclass(formcls) and issubclass(formcls, Form):
return formcls
elif isinstance(formcls, (str, unicode)):
path = settings.FO... | python | def get_form(formcls):
"""
get form class according form class path or form class object
"""
from uliweb.form import Form
import inspect
if inspect.isclass(formcls) and issubclass(formcls, Form):
return formcls
elif isinstance(formcls, (str, unicode)):
path = settings.FO... | [
"def",
"get_form",
"(",
"formcls",
")",
":",
"from",
"uliweb",
".",
"form",
"import",
"Form",
"import",
"inspect",
"if",
"inspect",
".",
"isclass",
"(",
"formcls",
")",
"and",
"issubclass",
"(",
"formcls",
",",
"Form",
")",
":",
"return",
"formcls",
"eli... | get form class according form class path or form class object | [
"get",
"form",
"class",
"according",
"form",
"class",
"path",
"or",
"form",
"class",
"object"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/contrib/form/__init__.py#L6-L23 |
7,049 | limodou/uliweb | uliweb/lib/werkzeug/script.py | run | def run(namespace=None, action_prefix='action_', args=None):
"""Run the script. Participating actions are looked up in the caller's
namespace if no namespace is given, otherwise in the dict provided.
Only items that start with action_prefix are processed as actions. If
you want to use all items in the... | python | def run(namespace=None, action_prefix='action_', args=None):
"""Run the script. Participating actions are looked up in the caller's
namespace if no namespace is given, otherwise in the dict provided.
Only items that start with action_prefix are processed as actions. If
you want to use all items in the... | [
"def",
"run",
"(",
"namespace",
"=",
"None",
",",
"action_prefix",
"=",
"'action_'",
",",
"args",
"=",
"None",
")",
":",
"if",
"namespace",
"is",
"None",
":",
"namespace",
"=",
"sys",
".",
"_getframe",
"(",
"1",
")",
".",
"f_locals",
"actions",
"=",
... | Run the script. Participating actions are looked up in the caller's
namespace if no namespace is given, otherwise in the dict provided.
Only items that start with action_prefix are processed as actions. If
you want to use all items in the namespace provided as actions set
action_prefix to an empty str... | [
"Run",
"the",
"script",
".",
"Participating",
"actions",
"are",
"looked",
"up",
"in",
"the",
"caller",
"s",
"namespace",
"if",
"no",
"namespace",
"is",
"given",
"otherwise",
"in",
"the",
"dict",
"provided",
".",
"Only",
"items",
"that",
"start",
"with",
"a... | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/script.py#L98-L177 |
7,050 | limodou/uliweb | uliweb/lib/werkzeug/script.py | fail | def fail(message, code=-1):
"""Fail with an error."""
print('Error: %s' % message, file=sys.stderr)
sys.exit(code) | python | def fail(message, code=-1):
"""Fail with an error."""
print('Error: %s' % message, file=sys.stderr)
sys.exit(code) | [
"def",
"fail",
"(",
"message",
",",
"code",
"=",
"-",
"1",
")",
":",
"print",
"(",
"'Error: %s'",
"%",
"message",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"sys",
".",
"exit",
"(",
"code",
")"
] | Fail with an error. | [
"Fail",
"with",
"an",
"error",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/script.py#L180-L183 |
7,051 | limodou/uliweb | uliweb/lib/werkzeug/script.py | find_actions | def find_actions(namespace, action_prefix):
"""Find all the actions in the namespace."""
actions = {}
for key, value in iteritems(namespace):
if key.startswith(action_prefix):
actions[key[len(action_prefix):]] = analyse_action(value)
return actions | python | def find_actions(namespace, action_prefix):
"""Find all the actions in the namespace."""
actions = {}
for key, value in iteritems(namespace):
if key.startswith(action_prefix):
actions[key[len(action_prefix):]] = analyse_action(value)
return actions | [
"def",
"find_actions",
"(",
"namespace",
",",
"action_prefix",
")",
":",
"actions",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"iteritems",
"(",
"namespace",
")",
":",
"if",
"key",
".",
"startswith",
"(",
"action_prefix",
")",
":",
"actions",
"[",
... | Find all the actions in the namespace. | [
"Find",
"all",
"the",
"actions",
"in",
"the",
"namespace",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/script.py#L186-L192 |
7,052 | limodou/uliweb | uliweb/lib/werkzeug/script.py | analyse_action | def analyse_action(func):
"""Analyse a function."""
description = inspect.getdoc(func) or 'undocumented action'
arguments = []
args, varargs, kwargs, defaults = inspect.getargspec(func)
if varargs or kwargs:
raise TypeError('variable length arguments for action not allowed.')
if len(args... | python | def analyse_action(func):
"""Analyse a function."""
description = inspect.getdoc(func) or 'undocumented action'
arguments = []
args, varargs, kwargs, defaults = inspect.getargspec(func)
if varargs or kwargs:
raise TypeError('variable length arguments for action not allowed.')
if len(args... | [
"def",
"analyse_action",
"(",
"func",
")",
":",
"description",
"=",
"inspect",
".",
"getdoc",
"(",
"func",
")",
"or",
"'undocumented action'",
"arguments",
"=",
"[",
"]",
"args",
",",
"varargs",
",",
"kwargs",
",",
"defaults",
"=",
"inspect",
".",
"getargs... | Analyse a function. | [
"Analyse",
"a",
"function",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/script.py#L222-L245 |
7,053 | limodou/uliweb | uliweb/lib/werkzeug/script.py | make_shell | def make_shell(init_func=None, banner=None, use_ipython=True):
"""Returns an action callback that spawns a new interactive
python shell.
:param init_func: an optional initialization function that is
called before the shell is started. The return
value of this fu... | python | def make_shell(init_func=None, banner=None, use_ipython=True):
"""Returns an action callback that spawns a new interactive
python shell.
:param init_func: an optional initialization function that is
called before the shell is started. The return
value of this fu... | [
"def",
"make_shell",
"(",
"init_func",
"=",
"None",
",",
"banner",
"=",
"None",
",",
"use_ipython",
"=",
"True",
")",
":",
"if",
"banner",
"is",
"None",
":",
"banner",
"=",
"'Interactive Werkzeug Shell'",
"if",
"init_func",
"is",
"None",
":",
"init_func",
... | Returns an action callback that spawns a new interactive
python shell.
:param init_func: an optional initialization function that is
called before the shell is started. The return
value of this function is the initial namespace.
:param banner: the banner that is... | [
"Returns",
"an",
"action",
"callback",
"that",
"spawns",
"a",
"new",
"interactive",
"python",
"shell",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/script.py#L248-L281 |
7,054 | limodou/uliweb | uliweb/lib/werkzeug/script.py | make_runserver | def make_runserver(app_factory, hostname='localhost', port=5000,
use_reloader=False, use_debugger=False, use_evalex=True,
threaded=False, processes=1, static_files=None,
extra_files=None, ssl_context=None):
"""Returns an action callback that spawns a new deve... | python | def make_runserver(app_factory, hostname='localhost', port=5000,
use_reloader=False, use_debugger=False, use_evalex=True,
threaded=False, processes=1, static_files=None,
extra_files=None, ssl_context=None):
"""Returns an action callback that spawns a new deve... | [
"def",
"make_runserver",
"(",
"app_factory",
",",
"hostname",
"=",
"'localhost'",
",",
"port",
"=",
"5000",
",",
"use_reloader",
"=",
"False",
",",
"use_debugger",
"=",
"False",
",",
"use_evalex",
"=",
"True",
",",
"threaded",
"=",
"False",
",",
"processes",... | Returns an action callback that spawns a new development server.
.. versionadded:: 0.5
`static_files` and `extra_files` was added.
..versionadded:: 0.6.1
`ssl_context` was added.
:param app_factory: a function that returns a new WSGI application.
:param hostname: the default hostname th... | [
"Returns",
"an",
"action",
"callback",
"that",
"spawns",
"a",
"new",
"development",
"server",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/script.py#L284-L316 |
7,055 | limodou/uliweb | uliweb/core/dispatch.py | unbind | def unbind(topic, func):
"""
Remove receiver function
"""
if topic in _receivers:
receivers = _receivers[topic]
for i in range(len(receivers)-1, -1, -1):
nice, f = receivers[i]
if (callable(func) and f['func'] == func) or (f['func_name'] == func):
... | python | def unbind(topic, func):
"""
Remove receiver function
"""
if topic in _receivers:
receivers = _receivers[topic]
for i in range(len(receivers)-1, -1, -1):
nice, f = receivers[i]
if (callable(func) and f['func'] == func) or (f['func_name'] == func):
... | [
"def",
"unbind",
"(",
"topic",
",",
"func",
")",
":",
"if",
"topic",
"in",
"_receivers",
":",
"receivers",
"=",
"_receivers",
"[",
"topic",
"]",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"receivers",
")",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",... | Remove receiver function | [
"Remove",
"receiver",
"function"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/core/dispatch.py#L54-L64 |
7,056 | limodou/uliweb | uliweb/core/dispatch.py | call | def call(sender, topic, *args, **kwargs):
"""
Invoke receiver functions according topic, it'll invoke receiver functions one by one,
and it'll not return anything, so if you want to return a value, you should
use get function.
"""
if not topic in _receivers:
return
items = _r... | python | def call(sender, topic, *args, **kwargs):
"""
Invoke receiver functions according topic, it'll invoke receiver functions one by one,
and it'll not return anything, so if you want to return a value, you should
use get function.
"""
if not topic in _receivers:
return
items = _r... | [
"def",
"call",
"(",
"sender",
",",
"topic",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"topic",
"in",
"_receivers",
":",
"return",
"items",
"=",
"_receivers",
"[",
"topic",
"]",
"def",
"_cmp",
"(",
"x",
",",
"y",
")",
":",
... | Invoke receiver functions according topic, it'll invoke receiver functions one by one,
and it'll not return anything, so if you want to return a value, you should
use get function. | [
"Invoke",
"receiver",
"functions",
"according",
"topic",
"it",
"ll",
"invoke",
"receiver",
"functions",
"one",
"by",
"one",
"and",
"it",
"ll",
"not",
"return",
"anything",
"so",
"if",
"you",
"want",
"to",
"return",
"a",
"value",
"you",
"should",
"use",
"ge... | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/core/dispatch.py#L82-L118 |
7,057 | limodou/uliweb | uliweb/core/dispatch.py | get | def get(sender, topic, *args, **kwargs):
"""
Invoke receiver functions according topic, it'll invoke receiver functions one by one,
and if one receiver function return non-None value, it'll return it and break
the loop.
"""
if not topic in _receivers:
return
items = _receiver... | python | def get(sender, topic, *args, **kwargs):
"""
Invoke receiver functions according topic, it'll invoke receiver functions one by one,
and if one receiver function return non-None value, it'll return it and break
the loop.
"""
if not topic in _receivers:
return
items = _receiver... | [
"def",
"get",
"(",
"sender",
",",
"topic",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"topic",
"in",
"_receivers",
":",
"return",
"items",
"=",
"_receivers",
"[",
"topic",
"]",
"def",
"_cmp",
"(",
"x",
",",
"y",
")",
":",
... | Invoke receiver functions according topic, it'll invoke receiver functions one by one,
and if one receiver function return non-None value, it'll return it and break
the loop. | [
"Invoke",
"receiver",
"functions",
"according",
"topic",
"it",
"ll",
"invoke",
"receiver",
"functions",
"one",
"by",
"one",
"and",
"if",
"one",
"receiver",
"function",
"return",
"non",
"-",
"None",
"value",
"it",
"ll",
"return",
"it",
"and",
"break",
"the",
... | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/core/dispatch.py#L128-L163 |
7,058 | limodou/uliweb | uliweb/utils/pyini.py | Ini.__read_line | def __read_line(self, f):
"""
Get logic line according the syntax not the physical line
It'll return the line text and if there is identifier existed
return line, bool
"""
g = tokenize.generate_tokens(f.readline)
buf = []
time =... | python | def __read_line(self, f):
"""
Get logic line according the syntax not the physical line
It'll return the line text and if there is identifier existed
return line, bool
"""
g = tokenize.generate_tokens(f.readline)
buf = []
time =... | [
"def",
"__read_line",
"(",
"self",
",",
"f",
")",
":",
"g",
"=",
"tokenize",
".",
"generate_tokens",
"(",
"f",
".",
"readline",
")",
"buf",
"=",
"[",
"]",
"time",
"=",
"0",
"iden_existed",
"=",
"False",
"while",
"1",
":",
"v",
"=",
"g",
".",
"nex... | Get logic line according the syntax not the physical line
It'll return the line text and if there is identifier existed
return line, bool | [
"Get",
"logic",
"line",
"according",
"the",
"syntax",
"not",
"the",
"physical",
"line",
"It",
"ll",
"return",
"the",
"line",
"text",
"and",
"if",
"there",
"is",
"identifier",
"existed",
"return",
"line",
"bool"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/utils/pyini.py#L611-L638 |
7,059 | limodou/uliweb | uliweb/utils/pyini.py | Ini.freeze | def freeze(self):
"""
Process all EvalValue to real value
"""
self._lazy = False
for k, v in self.items():
if k in self._env:
continue
for _k, _v in v.items():
if isinstance(_v, Lazy):
if self.w... | python | def freeze(self):
"""
Process all EvalValue to real value
"""
self._lazy = False
for k, v in self.items():
if k in self._env:
continue
for _k, _v in v.items():
if isinstance(_v, Lazy):
if self.w... | [
"def",
"freeze",
"(",
"self",
")",
":",
"self",
".",
"_lazy",
"=",
"False",
"for",
"k",
",",
"v",
"in",
"self",
".",
"items",
"(",
")",
":",
"if",
"k",
"in",
"self",
".",
"_env",
":",
"continue",
"for",
"_k",
",",
"_v",
"in",
"v",
".",
"items... | Process all EvalValue to real value | [
"Process",
"all",
"EvalValue",
"to",
"real",
"value"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/utils/pyini.py#L708-L727 |
7,060 | limodou/uliweb | uliweb/lib/werkzeug/contrib/securecookie.py | SecureCookie.serialize | def serialize(self, expires=None):
"""Serialize the secure cookie into a string.
If expires is provided, the session will be automatically invalidated
after expiration when you unseralize it. This provides better
protection against session cookie theft.
:param expires: an optio... | python | def serialize(self, expires=None):
"""Serialize the secure cookie into a string.
If expires is provided, the session will be automatically invalidated
after expiration when you unseralize it. This provides better
protection against session cookie theft.
:param expires: an optio... | [
"def",
"serialize",
"(",
"self",
",",
"expires",
"=",
"None",
")",
":",
"if",
"self",
".",
"secret_key",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"'no secret key defined'",
")",
"if",
"expires",
":",
"self",
"[",
"'_expires'",
"]",
"=",
"_date_to_u... | Serialize the secure cookie into a string.
If expires is provided, the session will be automatically invalidated
after expiration when you unseralize it. This provides better
protection against session cookie theft.
:param expires: an optional expiration date for the cookie (a
... | [
"Serialize",
"the",
"secure",
"cookie",
"into",
"a",
"string",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/contrib/securecookie.py#L203-L228 |
7,061 | limodou/uliweb | uliweb/lib/werkzeug/contrib/securecookie.py | SecureCookie.unserialize | def unserialize(cls, string, secret_key):
"""Load the secure cookie from a serialized string.
:param string: the cookie value to unserialize.
:param secret_key: the secret key used to serialize the cookie.
:return: a new :class:`SecureCookie`.
"""
if isinstance(string, t... | python | def unserialize(cls, string, secret_key):
"""Load the secure cookie from a serialized string.
:param string: the cookie value to unserialize.
:param secret_key: the secret key used to serialize the cookie.
:return: a new :class:`SecureCookie`.
"""
if isinstance(string, t... | [
"def",
"unserialize",
"(",
"cls",
",",
"string",
",",
"secret_key",
")",
":",
"if",
"isinstance",
"(",
"string",
",",
"text_type",
")",
":",
"string",
"=",
"string",
".",
"encode",
"(",
"'utf-8'",
",",
"'replace'",
")",
"if",
"isinstance",
"(",
"secret_k... | Load the secure cookie from a serialized string.
:param string: the cookie value to unserialize.
:param secret_key: the secret key used to serialize the cookie.
:return: a new :class:`SecureCookie`. | [
"Load",
"the",
"secure",
"cookie",
"from",
"a",
"serialized",
"string",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/contrib/securecookie.py#L231-L283 |
7,062 | limodou/uliweb | uliweb/contrib/model_config/__init__.py | find_model | def find_model(sender, model_name):
"""
Register new model to ORM
"""
MC = get_mc()
model = MC.get((MC.c.model_name==model_name) & (MC.c.uuid!=''))
if model:
model_inst = model.get_instance()
orm.set_model(model_name, model_inst.table_name, appname=__name__, model_path='')
... | python | def find_model(sender, model_name):
"""
Register new model to ORM
"""
MC = get_mc()
model = MC.get((MC.c.model_name==model_name) & (MC.c.uuid!=''))
if model:
model_inst = model.get_instance()
orm.set_model(model_name, model_inst.table_name, appname=__name__, model_path='')
... | [
"def",
"find_model",
"(",
"sender",
",",
"model_name",
")",
":",
"MC",
"=",
"get_mc",
"(",
")",
"model",
"=",
"MC",
".",
"get",
"(",
"(",
"MC",
".",
"c",
".",
"model_name",
"==",
"model_name",
")",
"&",
"(",
"MC",
".",
"c",
".",
"uuid",
"!=",
"... | Register new model to ORM | [
"Register",
"new",
"model",
"to",
"ORM"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/contrib/model_config/__init__.py#L20-L29 |
7,063 | limodou/uliweb | uliweb/contrib/model_config/__init__.py | get_model_fields | def get_model_fields(model, add_reserver_flag=True):
"""
Creating fields suit for model_config , id will be skipped.
"""
import uliweb.orm as orm
fields = []
m = {'type':'type_name', 'hint':'hint',
'default':'default', 'required':'required'}
m1 = {'index':'index', 'unique':'unique'... | python | def get_model_fields(model, add_reserver_flag=True):
"""
Creating fields suit for model_config , id will be skipped.
"""
import uliweb.orm as orm
fields = []
m = {'type':'type_name', 'hint':'hint',
'default':'default', 'required':'required'}
m1 = {'index':'index', 'unique':'unique'... | [
"def",
"get_model_fields",
"(",
"model",
",",
"add_reserver_flag",
"=",
"True",
")",
":",
"import",
"uliweb",
".",
"orm",
"as",
"orm",
"fields",
"=",
"[",
"]",
"m",
"=",
"{",
"'type'",
":",
"'type_name'",
",",
"'hint'",
":",
"'hint'",
",",
"'default'",
... | Creating fields suit for model_config , id will be skipped. | [
"Creating",
"fields",
"suit",
"for",
"model_config",
"id",
"will",
"be",
"skipped",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/contrib/model_config/__init__.py#L69-L100 |
7,064 | limodou/uliweb | uliweb/contrib/model_config/__init__.py | get_model_indexes | def get_model_indexes(model, add_reserver_flag=True):
"""
Creating indexes suit for model_config.
"""
import uliweb.orm as orm
from sqlalchemy.engine.reflection import Inspector
indexes = []
engine = model.get_engine().engine
insp = Inspector.from_engine(engine)
for index in insp.ge... | python | def get_model_indexes(model, add_reserver_flag=True):
"""
Creating indexes suit for model_config.
"""
import uliweb.orm as orm
from sqlalchemy.engine.reflection import Inspector
indexes = []
engine = model.get_engine().engine
insp = Inspector.from_engine(engine)
for index in insp.ge... | [
"def",
"get_model_indexes",
"(",
"model",
",",
"add_reserver_flag",
"=",
"True",
")",
":",
"import",
"uliweb",
".",
"orm",
"as",
"orm",
"from",
"sqlalchemy",
".",
"engine",
".",
"reflection",
"import",
"Inspector",
"indexes",
"=",
"[",
"]",
"engine",
"=",
... | Creating indexes suit for model_config. | [
"Creating",
"indexes",
"suit",
"for",
"model_config",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/contrib/model_config/__init__.py#L102-L121 |
7,065 | limodou/uliweb | uliweb/utils/timeit.py | timeit | def timeit(output):
"""
If output is string, then print the string and also time used
"""
b = time.time()
yield
print output, 'time used: %.3fs' % (time.time()-b) | python | def timeit(output):
"""
If output is string, then print the string and also time used
"""
b = time.time()
yield
print output, 'time used: %.3fs' % (time.time()-b) | [
"def",
"timeit",
"(",
"output",
")",
":",
"b",
"=",
"time",
".",
"time",
"(",
")",
"yield",
"print",
"output",
",",
"'time used: %.3fs'",
"%",
"(",
"time",
".",
"time",
"(",
")",
"-",
"b",
")"
] | If output is string, then print the string and also time used | [
"If",
"output",
"is",
"string",
"then",
"print",
"the",
"string",
"and",
"also",
"time",
"used"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/utils/timeit.py#L5-L11 |
7,066 | limodou/uliweb | uliweb/lib/werkzeug/wsgi.py | host_is_trusted | def host_is_trusted(hostname, trusted_list):
"""Checks if a host is trusted against a list. This also takes care
of port normalization.
.. versionadded:: 0.9
:param hostname: the hostname to check
:param trusted_list: a list of hostnames to check against. If a
hostname s... | python | def host_is_trusted(hostname, trusted_list):
"""Checks if a host is trusted against a list. This also takes care
of port normalization.
.. versionadded:: 0.9
:param hostname: the hostname to check
:param trusted_list: a list of hostnames to check against. If a
hostname s... | [
"def",
"host_is_trusted",
"(",
"hostname",
",",
"trusted_list",
")",
":",
"if",
"not",
"hostname",
":",
"return",
"False",
"if",
"isinstance",
"(",
"trusted_list",
",",
"string_types",
")",
":",
"trusted_list",
"=",
"[",
"trusted_list",
"]",
"def",
"_normalize... | Checks if a host is trusted against a list. This also takes care
of port normalization.
.. versionadded:: 0.9
:param hostname: the hostname to check
:param trusted_list: a list of hostnames to check against. If a
hostname starts with a dot it will match against
... | [
"Checks",
"if",
"a",
"host",
"is",
"trusted",
"against",
"a",
"list",
".",
"This",
"also",
"takes",
"care",
"of",
"port",
"normalization",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/wsgi.py#L85-L119 |
7,067 | limodou/uliweb | uliweb/lib/werkzeug/wsgi.py | get_content_length | def get_content_length(environ):
"""Returns the content length from the WSGI environment as
integer. If it's not available `None` is returned.
.. versionadded:: 0.9
:param environ: the WSGI environ to fetch the content length from.
"""
content_length = environ.get('CONTENT_LENGTH')
if con... | python | def get_content_length(environ):
"""Returns the content length from the WSGI environment as
integer. If it's not available `None` is returned.
.. versionadded:: 0.9
:param environ: the WSGI environ to fetch the content length from.
"""
content_length = environ.get('CONTENT_LENGTH')
if con... | [
"def",
"get_content_length",
"(",
"environ",
")",
":",
"content_length",
"=",
"environ",
".",
"get",
"(",
"'CONTENT_LENGTH'",
")",
"if",
"content_length",
"is",
"not",
"None",
":",
"try",
":",
"return",
"max",
"(",
"0",
",",
"int",
"(",
"content_length",
"... | Returns the content length from the WSGI environment as
integer. If it's not available `None` is returned.
.. versionadded:: 0.9
:param environ: the WSGI environ to fetch the content length from. | [
"Returns",
"the",
"content",
"length",
"from",
"the",
"WSGI",
"environment",
"as",
"integer",
".",
"If",
"it",
"s",
"not",
"available",
"None",
"is",
"returned",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/wsgi.py#L148-L161 |
7,068 | limodou/uliweb | uliweb/lib/werkzeug/wsgi.py | get_input_stream | def get_input_stream(environ, safe_fallback=True):
"""Returns the input stream from the WSGI environment and wraps it
in the most sensible way possible. The stream returned is not the
raw WSGI stream in most cases but one that is safe to read from
without taking into account the content length.
..... | python | def get_input_stream(environ, safe_fallback=True):
"""Returns the input stream from the WSGI environment and wraps it
in the most sensible way possible. The stream returned is not the
raw WSGI stream in most cases but one that is safe to read from
without taking into account the content length.
..... | [
"def",
"get_input_stream",
"(",
"environ",
",",
"safe_fallback",
"=",
"True",
")",
":",
"stream",
"=",
"environ",
"[",
"'wsgi.input'",
"]",
"content_length",
"=",
"get_content_length",
"(",
"environ",
")",
"# A wsgi extension that tells us if the input is terminated. In"... | Returns the input stream from the WSGI environment and wraps it
in the most sensible way possible. The stream returned is not the
raw WSGI stream in most cases but one that is safe to read from
without taking into account the content length.
.. versionadded:: 0.9
:param environ: the WSGI environ ... | [
"Returns",
"the",
"input",
"stream",
"from",
"the",
"WSGI",
"environment",
"and",
"wraps",
"it",
"in",
"the",
"most",
"sensible",
"way",
"possible",
".",
"The",
"stream",
"returned",
"is",
"not",
"the",
"raw",
"WSGI",
"stream",
"in",
"most",
"cases",
"but"... | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/wsgi.py#L164-L195 |
7,069 | limodou/uliweb | uliweb/lib/werkzeug/wsgi.py | get_path_info | def get_path_info(environ, charset='utf-8', errors='replace'):
"""Returns the `PATH_INFO` from the WSGI environment and properly
decodes it. This also takes care about the WSGI decoding dance
on Python 3 environments. if the `charset` is set to `None` a
bytestring is returned.
.. versionadded:: 0... | python | def get_path_info(environ, charset='utf-8', errors='replace'):
"""Returns the `PATH_INFO` from the WSGI environment and properly
decodes it. This also takes care about the WSGI decoding dance
on Python 3 environments. if the `charset` is set to `None` a
bytestring is returned.
.. versionadded:: 0... | [
"def",
"get_path_info",
"(",
"environ",
",",
"charset",
"=",
"'utf-8'",
",",
"errors",
"=",
"'replace'",
")",
":",
"path",
"=",
"wsgi_get_bytes",
"(",
"environ",
".",
"get",
"(",
"'PATH_INFO'",
",",
"''",
")",
")",
"return",
"to_unicode",
"(",
"path",
",... | Returns the `PATH_INFO` from the WSGI environment and properly
decodes it. This also takes care about the WSGI decoding dance
on Python 3 environments. if the `charset` is set to `None` a
bytestring is returned.
.. versionadded:: 0.9
:param environ: the WSGI environment object to get the path fr... | [
"Returns",
"the",
"PATH_INFO",
"from",
"the",
"WSGI",
"environment",
"and",
"properly",
"decodes",
"it",
".",
"This",
"also",
"takes",
"care",
"about",
"the",
"WSGI",
"decoding",
"dance",
"on",
"Python",
"3",
"environments",
".",
"if",
"the",
"charset",
"is"... | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/wsgi.py#L215-L229 |
7,070 | limodou/uliweb | uliweb/lib/werkzeug/wsgi.py | pop_path_info | def pop_path_info(environ, charset='utf-8', errors='replace'):
"""Removes and returns the next segment of `PATH_INFO`, pushing it onto
`SCRIPT_NAME`. Returns `None` if there is nothing left on `PATH_INFO`.
If the `charset` is set to `None` a bytestring is returned.
If there are empty segments (``'/fo... | python | def pop_path_info(environ, charset='utf-8', errors='replace'):
"""Removes and returns the next segment of `PATH_INFO`, pushing it onto
`SCRIPT_NAME`. Returns `None` if there is nothing left on `PATH_INFO`.
If the `charset` is set to `None` a bytestring is returned.
If there are empty segments (``'/fo... | [
"def",
"pop_path_info",
"(",
"environ",
",",
"charset",
"=",
"'utf-8'",
",",
"errors",
"=",
"'replace'",
")",
":",
"path",
"=",
"environ",
".",
"get",
"(",
"'PATH_INFO'",
")",
"if",
"not",
"path",
":",
"return",
"None",
"script_name",
"=",
"environ",
"."... | Removes and returns the next segment of `PATH_INFO`, pushing it onto
`SCRIPT_NAME`. Returns `None` if there is nothing left on `PATH_INFO`.
If the `charset` is set to `None` a bytestring is returned.
If there are empty segments (``'/foo//bar``) these are ignored but
properly pushed to the `SCRIPT_NAM... | [
"Removes",
"and",
"returns",
"the",
"next",
"segment",
"of",
"PATH_INFO",
"pushing",
"it",
"onto",
"SCRIPT_NAME",
".",
"Returns",
"None",
"if",
"there",
"is",
"nothing",
"left",
"on",
"PATH_INFO",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/wsgi.py#L249-L298 |
7,071 | limodou/uliweb | uliweb/lib/werkzeug/wsgi.py | _make_chunk_iter | def _make_chunk_iter(stream, limit, buffer_size):
"""Helper for the line and chunk iter functions."""
if isinstance(stream, (bytes, bytearray, text_type)):
raise TypeError('Passed a string or byte object instead of '
'true iterator or stream.')
if not hasattr(stream, 'read'):... | python | def _make_chunk_iter(stream, limit, buffer_size):
"""Helper for the line and chunk iter functions."""
if isinstance(stream, (bytes, bytearray, text_type)):
raise TypeError('Passed a string or byte object instead of '
'true iterator or stream.')
if not hasattr(stream, 'read'):... | [
"def",
"_make_chunk_iter",
"(",
"stream",
",",
"limit",
",",
"buffer_size",
")",
":",
"if",
"isinstance",
"(",
"stream",
",",
"(",
"bytes",
",",
"bytearray",
",",
"text_type",
")",
")",
":",
"raise",
"TypeError",
"(",
"'Passed a string or byte object instead of ... | Helper for the line and chunk iter functions. | [
"Helper",
"for",
"the",
"line",
"and",
"chunk",
"iter",
"functions",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/wsgi.py#L745-L762 |
7,072 | limodou/uliweb | uliweb/contrib/soap/__init__.py | soap | def soap(func=None, name=None, returns=None, args=None, doc=None, target='SOAP'):
"""
soap supports multiple SOAP function collections, it'll save functions to
target dict, and you can give other target, but it should be keep up with
SoapView.target definition.
"""
global __soap_functions__
... | python | def soap(func=None, name=None, returns=None, args=None, doc=None, target='SOAP'):
"""
soap supports multiple SOAP function collections, it'll save functions to
target dict, and you can give other target, but it should be keep up with
SoapView.target definition.
"""
global __soap_functions__
... | [
"def",
"soap",
"(",
"func",
"=",
"None",
",",
"name",
"=",
"None",
",",
"returns",
"=",
"None",
",",
"args",
"=",
"None",
",",
"doc",
"=",
"None",
",",
"target",
"=",
"'SOAP'",
")",
":",
"global",
"__soap_functions__",
"returns",
"=",
"_fix_soap_kwargs... | soap supports multiple SOAP function collections, it'll save functions to
target dict, and you can give other target, but it should be keep up with
SoapView.target definition. | [
"soap",
"supports",
"multiple",
"SOAP",
"function",
"collections",
"it",
"ll",
"save",
"functions",
"to",
"target",
"dict",
"and",
"you",
"can",
"give",
"other",
"target",
"but",
"it",
"should",
"be",
"keep",
"up",
"with",
"SoapView",
".",
"target",
"definit... | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/contrib/soap/__init__.py#L27-L68 |
7,073 | adamhajari/spyre | spyre/server.py | App.getJsonData | def getJsonData(self, params):
"""turns the DataFrame returned by getData into a dictionary
arguments:
the params passed used for table or d3 outputs are forwarded on to getData
"""
try:
return eval("self." + str(params['output_id']) + "(params)")
except Attr... | python | def getJsonData(self, params):
"""turns the DataFrame returned by getData into a dictionary
arguments:
the params passed used for table or d3 outputs are forwarded on to getData
"""
try:
return eval("self." + str(params['output_id']) + "(params)")
except Attr... | [
"def",
"getJsonData",
"(",
"self",
",",
"params",
")",
":",
"try",
":",
"return",
"eval",
"(",
"\"self.\"",
"+",
"str",
"(",
"params",
"[",
"'output_id'",
"]",
")",
"+",
"\"(params)\"",
")",
"except",
"AttributeError",
":",
"df",
"=",
"self",
".",
"get... | turns the DataFrame returned by getData into a dictionary
arguments:
the params passed used for table or d3 outputs are forwarded on to getData | [
"turns",
"the",
"DataFrame",
"returned",
"by",
"getData",
"into",
"a",
"dictionary"
] | 5dd9f6de072e99af636ab7e7393d249761c56e69 | https://github.com/adamhajari/spyre/blob/5dd9f6de072e99af636ab7e7393d249761c56e69/spyre/server.py#L330-L342 |
7,074 | adamhajari/spyre | spyre/server.py | App.launch_in_notebook | def launch_in_notebook(self, port=9095, width=900, height=600):
"""launch the app within an iframe in ipython notebook"""
from IPython.lib import backgroundjobs as bg
from IPython.display import HTML
jobs = bg.BackgroundJobManager()
jobs.new(self.launch, kw=dict(port=port))
... | python | def launch_in_notebook(self, port=9095, width=900, height=600):
"""launch the app within an iframe in ipython notebook"""
from IPython.lib import backgroundjobs as bg
from IPython.display import HTML
jobs = bg.BackgroundJobManager()
jobs.new(self.launch, kw=dict(port=port))
... | [
"def",
"launch_in_notebook",
"(",
"self",
",",
"port",
"=",
"9095",
",",
"width",
"=",
"900",
",",
"height",
"=",
"600",
")",
":",
"from",
"IPython",
".",
"lib",
"import",
"backgroundjobs",
"as",
"bg",
"from",
"IPython",
".",
"display",
"import",
"HTML",... | launch the app within an iframe in ipython notebook | [
"launch",
"the",
"app",
"within",
"an",
"iframe",
"in",
"ipython",
"notebook"
] | 5dd9f6de072e99af636ab7e7393d249761c56e69 | https://github.com/adamhajari/spyre/blob/5dd9f6de072e99af636ab7e7393d249761c56e69/spyre/server.py#L469-L480 |
7,075 | adamhajari/spyre | spyre/server.py | Site.launch | def launch(self, host="local", port=8080):
"""Calling the Launch method on a Site object will serve the top
node of the cherrypy Root object tree"""
# Need to add in the appbar if many apps
self.root.templateVars['app_bar'] = self.site_app_bar
for fullRoute, _ in self.site_a... | python | def launch(self, host="local", port=8080):
"""Calling the Launch method on a Site object will serve the top
node of the cherrypy Root object tree"""
# Need to add in the appbar if many apps
self.root.templateVars['app_bar'] = self.site_app_bar
for fullRoute, _ in self.site_a... | [
"def",
"launch",
"(",
"self",
",",
"host",
"=",
"\"local\"",
",",
"port",
"=",
"8080",
")",
":",
"# Need to add in the appbar if many apps",
"self",
".",
"root",
".",
"templateVars",
"[",
"'app_bar'",
"]",
"=",
"self",
".",
"site_app_bar",
"for",
"fullRoute",
... | Calling the Launch method on a Site object will serve the top
node of the cherrypy Root object tree | [
"Calling",
"the",
"Launch",
"method",
"on",
"a",
"Site",
"object",
"will",
"serve",
"the",
"top",
"node",
"of",
"the",
"cherrypy",
"Root",
"object",
"tree"
] | 5dd9f6de072e99af636ab7e7393d249761c56e69 | https://github.com/adamhajari/spyre/blob/5dd9f6de072e99af636ab7e7393d249761c56e69/spyre/server.py#L552-L565 |
7,076 | googlefonts/fontmake | Lib/fontmake/__main__.py | exclude_args | def exclude_args(parser, args, excluded_args, target):
"""Delete options that are not appropriate for a following code path; exit
with an error if excluded options were passed in by the user.
argparse generates a namespace with all options it knows, but not every
attribute should be passed to all code ... | python | def exclude_args(parser, args, excluded_args, target):
"""Delete options that are not appropriate for a following code path; exit
with an error if excluded options were passed in by the user.
argparse generates a namespace with all options it knows, but not every
attribute should be passed to all code ... | [
"def",
"exclude_args",
"(",
"parser",
",",
"args",
",",
"excluded_args",
",",
"target",
")",
":",
"msg",
"=",
"'\"%s\" option invalid for %s'",
"for",
"argname",
"in",
"excluded_args",
":",
"if",
"argname",
"not",
"in",
"args",
":",
"continue",
"if",
"args",
... | Delete options that are not appropriate for a following code path; exit
with an error if excluded options were passed in by the user.
argparse generates a namespace with all options it knows, but not every
attribute should be passed to all code paths (i.e. options about
interpolation should not reach `... | [
"Delete",
"options",
"that",
"are",
"not",
"appropriate",
"for",
"a",
"following",
"code",
"path",
";",
"exit",
"with",
"an",
"error",
"if",
"excluded",
"options",
"were",
"passed",
"in",
"by",
"the",
"user",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/__main__.py#L42-L60 |
7,077 | googlefonts/fontmake | Lib/fontmake/font_project.py | _varLib_finder | def _varLib_finder(source, directory="", ext="ttf"):
"""Finder function to be used with varLib.build to find master TTFs given
the filename of the source UFO master as specified in the designspace.
It replaces the UFO directory with the one specified in 'directory'
argument, and replaces the file extens... | python | def _varLib_finder(source, directory="", ext="ttf"):
"""Finder function to be used with varLib.build to find master TTFs given
the filename of the source UFO master as specified in the designspace.
It replaces the UFO directory with the one specified in 'directory'
argument, and replaces the file extens... | [
"def",
"_varLib_finder",
"(",
"source",
",",
"directory",
"=",
"\"\"",
",",
"ext",
"=",
"\"ttf\"",
")",
":",
"fname",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"source",
")",
")",
"[",
"0",
"]",
"+",
"... | Finder function to be used with varLib.build to find master TTFs given
the filename of the source UFO master as specified in the designspace.
It replaces the UFO directory with the one specified in 'directory'
argument, and replaces the file extension with 'ext'. | [
"Finder",
"function",
"to",
"be",
"used",
"with",
"varLib",
".",
"build",
"to",
"find",
"master",
"TTFs",
"given",
"the",
"filename",
"of",
"the",
"source",
"UFO",
"master",
"as",
"specified",
"in",
"the",
"designspace",
".",
"It",
"replaces",
"the",
"UFO"... | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L1158-L1165 |
7,078 | googlefonts/fontmake | Lib/fontmake/font_project.py | FontProject.build_master_ufos | def build_master_ufos(
self,
glyphs_path,
designspace_path=None,
master_dir=None,
instance_dir=None,
family_name=None,
mti_source=None,
):
"""Build UFOs and MutatorMath designspace from Glyphs source."""
import glyphsLib
if master_dir ... | python | def build_master_ufos(
self,
glyphs_path,
designspace_path=None,
master_dir=None,
instance_dir=None,
family_name=None,
mti_source=None,
):
"""Build UFOs and MutatorMath designspace from Glyphs source."""
import glyphsLib
if master_dir ... | [
"def",
"build_master_ufos",
"(",
"self",
",",
"glyphs_path",
",",
"designspace_path",
"=",
"None",
",",
"master_dir",
"=",
"None",
",",
"instance_dir",
"=",
"None",
",",
"family_name",
"=",
"None",
",",
"mti_source",
"=",
"None",
",",
")",
":",
"import",
"... | Build UFOs and MutatorMath designspace from Glyphs source. | [
"Build",
"UFOs",
"and",
"MutatorMath",
"designspace",
"from",
"Glyphs",
"source",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L110-L163 |
7,079 | googlefonts/fontmake | Lib/fontmake/font_project.py | FontProject.remove_overlaps | def remove_overlaps(self, ufos, glyph_filter=lambda g: len(g)):
"""Remove overlaps in UFOs' glyphs' contours."""
from booleanOperations import union, BooleanOperationsError
for ufo in ufos:
font_name = self._font_name(ufo)
logger.info("Removing overlaps for " + font_name... | python | def remove_overlaps(self, ufos, glyph_filter=lambda g: len(g)):
"""Remove overlaps in UFOs' glyphs' contours."""
from booleanOperations import union, BooleanOperationsError
for ufo in ufos:
font_name = self._font_name(ufo)
logger.info("Removing overlaps for " + font_name... | [
"def",
"remove_overlaps",
"(",
"self",
",",
"ufos",
",",
"glyph_filter",
"=",
"lambda",
"g",
":",
"len",
"(",
"g",
")",
")",
":",
"from",
"booleanOperations",
"import",
"union",
",",
"BooleanOperationsError",
"for",
"ufo",
"in",
"ufos",
":",
"font_name",
"... | Remove overlaps in UFOs' glyphs' contours. | [
"Remove",
"overlaps",
"in",
"UFOs",
"glyphs",
"contours",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L187-L205 |
7,080 | googlefonts/fontmake | Lib/fontmake/font_project.py | FontProject.decompose_glyphs | def decompose_glyphs(self, ufos, glyph_filter=lambda g: True):
"""Move components of UFOs' glyphs to their outlines."""
for ufo in ufos:
logger.info("Decomposing glyphs for " + self._font_name(ufo))
for glyph in ufo:
if not glyph.components or not glyph_filter(gl... | python | def decompose_glyphs(self, ufos, glyph_filter=lambda g: True):
"""Move components of UFOs' glyphs to their outlines."""
for ufo in ufos:
logger.info("Decomposing glyphs for " + self._font_name(ufo))
for glyph in ufo:
if not glyph.components or not glyph_filter(gl... | [
"def",
"decompose_glyphs",
"(",
"self",
",",
"ufos",
",",
"glyph_filter",
"=",
"lambda",
"g",
":",
"True",
")",
":",
"for",
"ufo",
"in",
"ufos",
":",
"logger",
".",
"info",
"(",
"\"Decomposing glyphs for \"",
"+",
"self",
".",
"_font_name",
"(",
"ufo",
"... | Move components of UFOs' glyphs to their outlines. | [
"Move",
"components",
"of",
"UFOs",
"glyphs",
"to",
"their",
"outlines",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L209-L218 |
7,081 | googlefonts/fontmake | Lib/fontmake/font_project.py | FontProject.build_ttfs | def build_ttfs(self, ufos, **kwargs):
"""Build OpenType binaries with TrueType outlines."""
self.save_otfs(ufos, ttf=True, **kwargs) | python | def build_ttfs(self, ufos, **kwargs):
"""Build OpenType binaries with TrueType outlines."""
self.save_otfs(ufos, ttf=True, **kwargs) | [
"def",
"build_ttfs",
"(",
"self",
",",
"ufos",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"save_otfs",
"(",
"ufos",
",",
"ttf",
"=",
"True",
",",
"*",
"*",
"kwargs",
")"
] | Build OpenType binaries with TrueType outlines. | [
"Build",
"OpenType",
"binaries",
"with",
"TrueType",
"outlines",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L271-L273 |
7,082 | googlefonts/fontmake | Lib/fontmake/font_project.py | FontProject.build_variable_font | def build_variable_font(
self,
designspace,
output_path=None,
output_dir=None,
master_bin_dir=None,
ttf=True,
):
"""Build OpenType variable font from masters in a designspace."""
assert not (output_path and output_dir), "mutually exclusive args"
... | python | def build_variable_font(
self,
designspace,
output_path=None,
output_dir=None,
master_bin_dir=None,
ttf=True,
):
"""Build OpenType variable font from masters in a designspace."""
assert not (output_path and output_dir), "mutually exclusive args"
... | [
"def",
"build_variable_font",
"(",
"self",
",",
"designspace",
",",
"output_path",
"=",
"None",
",",
"output_dir",
"=",
"None",
",",
"master_bin_dir",
"=",
"None",
",",
"ttf",
"=",
"True",
",",
")",
":",
"assert",
"not",
"(",
"output_path",
"and",
"output_... | Build OpenType variable font from masters in a designspace. | [
"Build",
"OpenType",
"variable",
"font",
"from",
"masters",
"in",
"a",
"designspace",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L341-L377 |
7,083 | googlefonts/fontmake | Lib/fontmake/font_project.py | FontProject.subset_otf_from_ufo | def subset_otf_from_ufo(self, otf_path, ufo):
"""Subset a font using export flags set by glyphsLib.
There are two more settings that can change export behavior:
"Export Glyphs" and "Remove Glyphs", which are currently not supported
for complexity reasons. See
https://github.com/... | python | def subset_otf_from_ufo(self, otf_path, ufo):
"""Subset a font using export flags set by glyphsLib.
There are two more settings that can change export behavior:
"Export Glyphs" and "Remove Glyphs", which are currently not supported
for complexity reasons. See
https://github.com/... | [
"def",
"subset_otf_from_ufo",
"(",
"self",
",",
"otf_path",
",",
"ufo",
")",
":",
"from",
"fontTools",
"import",
"subset",
"# ufo2ft always inserts a \".notdef\" glyph as the first glyph",
"ufo_order",
"=",
"makeOfficialGlyphOrder",
"(",
"ufo",
")",
"if",
"\".notdef\"",
... | Subset a font using export flags set by glyphsLib.
There are two more settings that can change export behavior:
"Export Glyphs" and "Remove Glyphs", which are currently not supported
for complexity reasons. See
https://github.com/googlei18n/glyphsLib/issues/295. | [
"Subset",
"a",
"font",
"using",
"export",
"flags",
"set",
"by",
"glyphsLib",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L625-L680 |
7,084 | googlefonts/fontmake | Lib/fontmake/font_project.py | FontProject.run_from_glyphs | def run_from_glyphs(
self,
glyphs_path,
designspace_path=None,
master_dir=None,
instance_dir=None,
family_name=None,
mti_source=None,
**kwargs
):
"""Run toolchain from Glyphs source.
Args:
glyphs_path: Path to source file.
... | python | def run_from_glyphs(
self,
glyphs_path,
designspace_path=None,
master_dir=None,
instance_dir=None,
family_name=None,
mti_source=None,
**kwargs
):
"""Run toolchain from Glyphs source.
Args:
glyphs_path: Path to source file.
... | [
"def",
"run_from_glyphs",
"(",
"self",
",",
"glyphs_path",
",",
"designspace_path",
"=",
"None",
",",
"master_dir",
"=",
"None",
",",
"instance_dir",
"=",
"None",
",",
"family_name",
"=",
"None",
",",
"mti_source",
"=",
"None",
",",
"*",
"*",
"kwargs",
")"... | Run toolchain from Glyphs source.
Args:
glyphs_path: Path to source file.
designspace_path: Output path of generated designspace document.
By default it's "<family_name>[-<base_style>].designspace".
master_dir: Directory where to save UFO masters (default:
... | [
"Run",
"toolchain",
"from",
"Glyphs",
"source",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L682-L719 |
7,085 | googlefonts/fontmake | Lib/fontmake/font_project.py | FontProject.interpolate_instance_ufos | def interpolate_instance_ufos(
self,
designspace,
include=None,
round_instances=False,
expand_features_to_instances=False,
):
"""Interpolate master UFOs with MutatorMath and return instance UFOs.
Args:
designspace: a DesignSpaceDocument object con... | python | def interpolate_instance_ufos(
self,
designspace,
include=None,
round_instances=False,
expand_features_to_instances=False,
):
"""Interpolate master UFOs with MutatorMath and return instance UFOs.
Args:
designspace: a DesignSpaceDocument object con... | [
"def",
"interpolate_instance_ufos",
"(",
"self",
",",
"designspace",
",",
"include",
"=",
"None",
",",
"round_instances",
"=",
"False",
",",
"expand_features_to_instances",
"=",
"False",
",",
")",
":",
"from",
"glyphsLib",
".",
"interpolation",
"import",
"apply_in... | Interpolate master UFOs with MutatorMath and return instance UFOs.
Args:
designspace: a DesignSpaceDocument object containing sources and
instances.
include (str): optional regular expression pattern to match the
DS instance 'name' attribute and only inte... | [
"Interpolate",
"master",
"UFOs",
"with",
"MutatorMath",
"and",
"return",
"instance",
"UFOs",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L721-L789 |
7,086 | googlefonts/fontmake | Lib/fontmake/font_project.py | FontProject.run_from_ufos | def run_from_ufos(self, ufos, output=(), **kwargs):
"""Run toolchain from UFO sources.
Args:
ufos: List of UFO sources, as either paths or opened objects.
output: List of output formats to generate.
kwargs: Arguments passed along to save_otfs.
"""
if... | python | def run_from_ufos(self, ufos, output=(), **kwargs):
"""Run toolchain from UFO sources.
Args:
ufos: List of UFO sources, as either paths or opened objects.
output: List of output formats to generate.
kwargs: Arguments passed along to save_otfs.
"""
if... | [
"def",
"run_from_ufos",
"(",
"self",
",",
"ufos",
",",
"output",
"=",
"(",
")",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"set",
"(",
"output",
")",
"==",
"{",
"\"ufo\"",
"}",
":",
"return",
"# the `ufos` parameter can be a list of UFO objects",
"# or it can ... | Run toolchain from UFO sources.
Args:
ufos: List of UFO sources, as either paths or opened objects.
output: List of output formats to generate.
kwargs: Arguments passed along to save_otfs. | [
"Run",
"toolchain",
"from",
"UFO",
"sources",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L943-L981 |
7,087 | googlefonts/fontmake | Lib/fontmake/font_project.py | FontProject._font_name | def _font_name(self, ufo):
"""Generate a postscript-style font name."""
family_name = (
ufo.info.familyName.replace(" ", "")
if ufo.info.familyName is not None
else "None"
)
style_name = (
ufo.info.styleName.replace(" ", "")
if ... | python | def _font_name(self, ufo):
"""Generate a postscript-style font name."""
family_name = (
ufo.info.familyName.replace(" ", "")
if ufo.info.familyName is not None
else "None"
)
style_name = (
ufo.info.styleName.replace(" ", "")
if ... | [
"def",
"_font_name",
"(",
"self",
",",
"ufo",
")",
":",
"family_name",
"=",
"(",
"ufo",
".",
"info",
".",
"familyName",
".",
"replace",
"(",
"\" \"",
",",
"\"\"",
")",
"if",
"ufo",
".",
"info",
".",
"familyName",
"is",
"not",
"None",
"else",
"\"None\... | Generate a postscript-style font name. | [
"Generate",
"a",
"postscript",
"-",
"style",
"font",
"name",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L994-L1006 |
7,088 | googlefonts/fontmake | Lib/fontmake/font_project.py | FontProject._output_dir | def _output_dir(
self,
ext,
is_instance=False,
interpolatable=False,
autohinted=False,
is_variable=False,
):
"""Generate an output directory.
Args:
ext: extension string.
is_instance: The output is instance font or ... | python | def _output_dir(
self,
ext,
is_instance=False,
interpolatable=False,
autohinted=False,
is_variable=False,
):
"""Generate an output directory.
Args:
ext: extension string.
is_instance: The output is instance font or ... | [
"def",
"_output_dir",
"(",
"self",
",",
"ext",
",",
"is_instance",
"=",
"False",
",",
"interpolatable",
"=",
"False",
",",
"autohinted",
"=",
"False",
",",
"is_variable",
"=",
"False",
",",
")",
":",
"assert",
"not",
"(",
"is_variable",
"and",
"any",
"("... | Generate an output directory.
Args:
ext: extension string.
is_instance: The output is instance font or not.
interpolatable: The output is interpolatable or not.
autohinted: The output is autohinted or not.
is_variable: The outp... | [
"Generate",
"an",
"output",
"directory",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L1008-L1040 |
7,089 | googlefonts/fontmake | Lib/fontmake/font_project.py | FontProject._output_path | def _output_path(
self,
ufo_or_font_name,
ext,
is_instance=False,
interpolatable=False,
autohinted=False,
is_variable=False,
output_dir=None,
suffix=None,
):
"""Generate output path for a font file with given extension."""
if i... | python | def _output_path(
self,
ufo_or_font_name,
ext,
is_instance=False,
interpolatable=False,
autohinted=False,
is_variable=False,
output_dir=None,
suffix=None,
):
"""Generate output path for a font file with given extension."""
if i... | [
"def",
"_output_path",
"(",
"self",
",",
"ufo_or_font_name",
",",
"ext",
",",
"is_instance",
"=",
"False",
",",
"interpolatable",
"=",
"False",
",",
"autohinted",
"=",
"False",
",",
"is_variable",
"=",
"False",
",",
"output_dir",
"=",
"None",
",",
"suffix",
... | Generate output path for a font file with given extension. | [
"Generate",
"output",
"path",
"for",
"a",
"font",
"file",
"with",
"given",
"extension",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L1042-L1074 |
7,090 | googlefonts/fontmake | Lib/fontmake/font_project.py | FontProject._designspace_locations | def _designspace_locations(self, designspace):
"""Map font filenames to their locations in a designspace."""
maps = []
for elements in (designspace.sources, designspace.instances):
location_map = {}
for element in elements:
path = _normpath(element.path)
... | python | def _designspace_locations(self, designspace):
"""Map font filenames to their locations in a designspace."""
maps = []
for elements in (designspace.sources, designspace.instances):
location_map = {}
for element in elements:
path = _normpath(element.path)
... | [
"def",
"_designspace_locations",
"(",
"self",
",",
"designspace",
")",
":",
"maps",
"=",
"[",
"]",
"for",
"elements",
"in",
"(",
"designspace",
".",
"sources",
",",
"designspace",
".",
"instances",
")",
":",
"location_map",
"=",
"{",
"}",
"for",
"element",... | Map font filenames to their locations in a designspace. | [
"Map",
"font",
"filenames",
"to",
"their",
"locations",
"in",
"a",
"designspace",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L1076-L1086 |
7,091 | googlefonts/fontmake | Lib/fontmake/font_project.py | FontProject._closest_location | def _closest_location(self, location_map, target):
"""Return path of font whose location is closest to target."""
def dist(a, b):
return math.sqrt(sum((a[k] - b[k]) ** 2 for k in a.keys()))
paths = iter(location_map.keys())
closest = next(paths)
closest_dist = dist(... | python | def _closest_location(self, location_map, target):
"""Return path of font whose location is closest to target."""
def dist(a, b):
return math.sqrt(sum((a[k] - b[k]) ** 2 for k in a.keys()))
paths = iter(location_map.keys())
closest = next(paths)
closest_dist = dist(... | [
"def",
"_closest_location",
"(",
"self",
",",
"location_map",
",",
"target",
")",
":",
"def",
"dist",
"(",
"a",
",",
"b",
")",
":",
"return",
"math",
".",
"sqrt",
"(",
"sum",
"(",
"(",
"a",
"[",
"k",
"]",
"-",
"b",
"[",
"k",
"]",
")",
"**",
"... | Return path of font whose location is closest to target. | [
"Return",
"path",
"of",
"font",
"whose",
"location",
"is",
"closest",
"to",
"target",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L1088-L1102 |
7,092 | googlefonts/fontmake | Lib/fontmake/ttfautohint.py | ttfautohint | def ttfautohint(in_file, out_file, args=None, **kwargs):
"""Thin wrapper around the ttfautohint command line tool.
Can take in command line arguments directly as a string, or spelled out as
Python keyword arguments.
"""
arg_list = ["ttfautohint"]
file_args = [in_file, out_file]
if args is... | python | def ttfautohint(in_file, out_file, args=None, **kwargs):
"""Thin wrapper around the ttfautohint command line tool.
Can take in command line arguments directly as a string, or spelled out as
Python keyword arguments.
"""
arg_list = ["ttfautohint"]
file_args = [in_file, out_file]
if args is... | [
"def",
"ttfautohint",
"(",
"in_file",
",",
"out_file",
",",
"args",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"arg_list",
"=",
"[",
"\"ttfautohint\"",
"]",
"file_args",
"=",
"[",
"in_file",
",",
"out_file",
"]",
"if",
"args",
"is",
"not",
"None",... | Thin wrapper around the ttfautohint command line tool.
Can take in command line arguments directly as a string, or spelled out as
Python keyword arguments. | [
"Thin",
"wrapper",
"around",
"the",
"ttfautohint",
"command",
"line",
"tool",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/ttfautohint.py#L21-L82 |
7,093 | ulule/python-logstash-formatter | logstash_formatter/__init__.py | _default_json_default | def _default_json_default(obj):
"""
Coerce everything to strings.
All objects representing time get output as ISO8601.
"""
if isinstance(obj, (datetime.datetime, datetime.date, datetime.time)):
return obj.isoformat()
else:
return str(obj) | python | def _default_json_default(obj):
"""
Coerce everything to strings.
All objects representing time get output as ISO8601.
"""
if isinstance(obj, (datetime.datetime, datetime.date, datetime.time)):
return obj.isoformat()
else:
return str(obj) | [
"def",
"_default_json_default",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"(",
"datetime",
".",
"datetime",
",",
"datetime",
".",
"date",
",",
"datetime",
".",
"time",
")",
")",
":",
"return",
"obj",
".",
"isoformat",
"(",
")",
"else",... | Coerce everything to strings.
All objects representing time get output as ISO8601. | [
"Coerce",
"everything",
"to",
"strings",
".",
"All",
"objects",
"representing",
"time",
"get",
"output",
"as",
"ISO8601",
"."
] | a29f7c8f5faec9467aaedfb74d5f40eacb2b50ea | https://github.com/ulule/python-logstash-formatter/blob/a29f7c8f5faec9467aaedfb74d5f40eacb2b50ea/logstash_formatter/__init__.py#L13-L21 |
7,094 | ulule/python-logstash-formatter | logstash_formatter/__init__.py | LogstashFormatter.format | def format(self, record):
"""
Format a log record to JSON, if the message is a dict
assume an empty message and use the dict as additional
fields.
"""
fields = record.__dict__.copy()
if isinstance(record.msg, dict):
fields.update(record.msg)
... | python | def format(self, record):
"""
Format a log record to JSON, if the message is a dict
assume an empty message and use the dict as additional
fields.
"""
fields = record.__dict__.copy()
if isinstance(record.msg, dict):
fields.update(record.msg)
... | [
"def",
"format",
"(",
"self",
",",
"record",
")",
":",
"fields",
"=",
"record",
".",
"__dict__",
".",
"copy",
"(",
")",
"if",
"isinstance",
"(",
"record",
".",
"msg",
",",
"dict",
")",
":",
"fields",
".",
"update",
"(",
"record",
".",
"msg",
")",
... | Format a log record to JSON, if the message is a dict
assume an empty message and use the dict as additional
fields. | [
"Format",
"a",
"log",
"record",
"to",
"JSON",
"if",
"the",
"message",
"is",
"a",
"dict",
"assume",
"an",
"empty",
"message",
"and",
"use",
"the",
"dict",
"as",
"additional",
"fields",
"."
] | a29f7c8f5faec9467aaedfb74d5f40eacb2b50ea | https://github.com/ulule/python-logstash-formatter/blob/a29f7c8f5faec9467aaedfb74d5f40eacb2b50ea/logstash_formatter/__init__.py#L65-L108 |
7,095 | ulule/python-logstash-formatter | logstash_formatter/__init__.py | LogstashFormatter._build_fields | def _build_fields(self, defaults, fields):
"""Return provided fields including any in defaults
>>> f = LogstashFormatter()
# Verify that ``fields`` is used
>>> f._build_fields({}, {'foo': 'one'}) == \
{'foo': 'one'}
True
# Verify that ``@fields`` in ``def... | python | def _build_fields(self, defaults, fields):
"""Return provided fields including any in defaults
>>> f = LogstashFormatter()
# Verify that ``fields`` is used
>>> f._build_fields({}, {'foo': 'one'}) == \
{'foo': 'one'}
True
# Verify that ``@fields`` in ``def... | [
"def",
"_build_fields",
"(",
"self",
",",
"defaults",
",",
"fields",
")",
":",
"return",
"dict",
"(",
"list",
"(",
"defaults",
".",
"get",
"(",
"'@fields'",
",",
"{",
"}",
")",
".",
"items",
"(",
")",
")",
"+",
"list",
"(",
"fields",
".",
"items",
... | Return provided fields including any in defaults
>>> f = LogstashFormatter()
# Verify that ``fields`` is used
>>> f._build_fields({}, {'foo': 'one'}) == \
{'foo': 'one'}
True
# Verify that ``@fields`` in ``defaults`` is used
>>> f._build_fields({'@fields'... | [
"Return",
"provided",
"fields",
"including",
"any",
"in",
"defaults"
] | a29f7c8f5faec9467aaedfb74d5f40eacb2b50ea | https://github.com/ulule/python-logstash-formatter/blob/a29f7c8f5faec9467aaedfb74d5f40eacb2b50ea/logstash_formatter/__init__.py#L110-L127 |
7,096 | tchellomello/python-arlo | pyarlo/__init__.py | PyArlo._authenticate | def _authenticate(self):
"""Authenticate user and generate token."""
self.cleanup_headers()
url = LOGIN_ENDPOINT
data = self.query(
url,
method='POST',
extra_params={
'email': self.__username,
'password': self.__password... | python | def _authenticate(self):
"""Authenticate user and generate token."""
self.cleanup_headers()
url = LOGIN_ENDPOINT
data = self.query(
url,
method='POST',
extra_params={
'email': self.__username,
'password': self.__password... | [
"def",
"_authenticate",
"(",
"self",
")",
":",
"self",
".",
"cleanup_headers",
"(",
")",
"url",
"=",
"LOGIN_ENDPOINT",
"data",
"=",
"self",
".",
"query",
"(",
"url",
",",
"method",
"=",
"'POST'",
",",
"extra_params",
"=",
"{",
"'email'",
":",
"self",
"... | Authenticate user and generate token. | [
"Authenticate",
"user",
"and",
"generate",
"token",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/__init__.py#L63-L84 |
7,097 | tchellomello/python-arlo | pyarlo/__init__.py | PyArlo.cleanup_headers | def cleanup_headers(self):
"""Reset the headers and params."""
headers = {'Content-Type': 'application/json'}
headers['Authorization'] = self.__token
self.__headers = headers
self.__params = {} | python | def cleanup_headers(self):
"""Reset the headers and params."""
headers = {'Content-Type': 'application/json'}
headers['Authorization'] = self.__token
self.__headers = headers
self.__params = {} | [
"def",
"cleanup_headers",
"(",
"self",
")",
":",
"headers",
"=",
"{",
"'Content-Type'",
":",
"'application/json'",
"}",
"headers",
"[",
"'Authorization'",
"]",
"=",
"self",
".",
"__token",
"self",
".",
"__headers",
"=",
"headers",
"self",
".",
"__params",
"=... | Reset the headers and params. | [
"Reset",
"the",
"headers",
"and",
"params",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/__init__.py#L86-L91 |
7,098 | tchellomello/python-arlo | pyarlo/__init__.py | PyArlo.query | def query(self,
url,
method='GET',
extra_params=None,
extra_headers=None,
retry=3,
raw=False,
stream=False):
"""
Return a JSON object or raw session.
:param url: Arlo API URL
:param method... | python | def query(self,
url,
method='GET',
extra_params=None,
extra_headers=None,
retry=3,
raw=False,
stream=False):
"""
Return a JSON object or raw session.
:param url: Arlo API URL
:param method... | [
"def",
"query",
"(",
"self",
",",
"url",
",",
"method",
"=",
"'GET'",
",",
"extra_params",
"=",
"None",
",",
"extra_headers",
"=",
"None",
",",
"retry",
"=",
"3",
",",
"raw",
"=",
"False",
",",
"stream",
"=",
"False",
")",
":",
"response",
"=",
"No... | Return a JSON object or raw session.
:param url: Arlo API URL
:param method: Specify the method GET, POST or PUT. Default is GET.
:param extra_params: Dictionary to be appended on request.body
:param extra_headers: Dictionary to be apppended on request.headers
:param retry: Att... | [
"Return",
"a",
"JSON",
"object",
"or",
"raw",
"session",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/__init__.py#L93-L158 |
7,099 | tchellomello/python-arlo | pyarlo/__init__.py | PyArlo.devices | def devices(self):
"""Return all devices on Arlo account."""
if self._all_devices:
return self._all_devices
self._all_devices = {}
self._all_devices['cameras'] = []
self._all_devices['base_station'] = []
url = DEVICES_ENDPOINT
data = self.query(url)
... | python | def devices(self):
"""Return all devices on Arlo account."""
if self._all_devices:
return self._all_devices
self._all_devices = {}
self._all_devices['cameras'] = []
self._all_devices['base_station'] = []
url = DEVICES_ENDPOINT
data = self.query(url)
... | [
"def",
"devices",
"(",
"self",
")",
":",
"if",
"self",
".",
"_all_devices",
":",
"return",
"self",
".",
"_all_devices",
"self",
".",
"_all_devices",
"=",
"{",
"}",
"self",
".",
"_all_devices",
"[",
"'cameras'",
"]",
"=",
"[",
"]",
"self",
".",
"_all_de... | Return all devices on Arlo account. | [
"Return",
"all",
"devices",
"on",
"Arlo",
"account",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/__init__.py#L171-L198 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.