function stringlengths 11 56k | repo_name stringlengths 5 60 | features list |
|---|---|---|
def create_dependency_processor(prop):
types = {
ONETOMANY : OneToManyDP,
MANYTOONE: ManyToOneDP,
MANYTOMANY : ManyToManyDP,
}
if prop.association is not None:
return AssociationDP(prop)
else:
return types[prop.direction](prop) | santisiri/popego | [
5,
2,
5,
1,
1476320366
] |
def __init__(self, prop):
self.prop = prop
self.cascade = prop.cascade
self.mapper = prop.mapper
self.parent = prop.parent
self.secondary = prop.secondary
self.direction = prop.direction
self.is_backref = prop.is_backref
self.post_update = prop.post_update... | santisiri/popego | [
5,
2,
5,
1,
1476320366
] |
def hasparent(self, state):
"""return True if the given object instance has a parent,
according to the ``InstrumentedAttribute`` handled by this ``DependencyProcessor``."""
# TODO: use correct API for this
return self._get_instrumented_attribute().impl.hasparent(state) | santisiri/popego | [
5,
2,
5,
1,
1476320366
] |
def whose_dependent_on_who(self, state1, state2):
"""Given an object pair assuming `obj2` is a child of `obj1`,
return a tuple with the dependent object second, or None if
there is no dependency.
"""
if state1 is state2:
return None
elif self.direction == ONE... | santisiri/popego | [
5,
2,
5,
1,
1476320366
] |
def preprocess_dependencies(self, task, deplist, uowcommit, delete = False):
"""Used before the flushes' topological sort to traverse
through related objects and ensure every instance which will
require save/update/delete is properly added to the
UOWTransaction.
"""
rais... | santisiri/popego | [
5,
2,
5,
1,
1476320366
] |
def _synchronize(self, state, child, associationrow, clearkeys, uowcommit):
"""Called during a flush to synchronize primary key identifier
values between a parent/child object, as well as to an
associationrow in the case of many-to-many.
"""
raise NotImplementedError() | santisiri/popego | [
5,
2,
5,
1,
1476320366
] |
def _pks_changed(self, uowcommit, state):
raise NotImplementedError() | santisiri/popego | [
5,
2,
5,
1,
1476320366
] |
def register_dependencies(self, uowcommit):
if self.post_update:
if not self.is_backref:
stub = MapperStub(self.parent, self.mapper, self.key)
uowcommit.register_dependency(self.mapper, stub)
uowcommit.register_dependency(self.parent, stub)
... | santisiri/popego | [
5,
2,
5,
1,
1476320366
] |
def preprocess_dependencies(self, task, deplist, uowcommit, delete = False):
#print self.mapper.mapped_table.name + " " + self.key + " " + repr(len(deplist)) + " preprocess_dep isdelete " + repr(delete) + " direction " + repr(self.direction)
if delete:
# head object is being deleted, and we... | santisiri/popego | [
5,
2,
5,
1,
1476320366
] |
def _pks_changed(self, uowcommit, state):
return sync.source_changes(uowcommit, state, self.parent, self.prop.synchronize_pairs) | santisiri/popego | [
5,
2,
5,
1,
1476320366
] |
def register_dependencies(self, uowcommit):
uowcommit.register_processor(self.parent, self, self.mapper) | santisiri/popego | [
5,
2,
5,
1,
1476320366
] |
def process_dependencies(self, task, deplist, uowcommit, delete=False):
# for passive updates, register objects in the process stage
# so that we avoid ManyToOneDP's registering the object without
# the listonly flag in its own preprocess stage (results in UPDATE)
# statements being emit... | santisiri/popego | [
5,
2,
5,
1,
1476320366
] |
def _pks_changed(self, uowcommit, state):
return sync.source_changes(uowcommit, state, self.mapper, self.prop.synchronize_pairs) | santisiri/popego | [
5,
2,
5,
1,
1476320366
] |
def __init__(self, prop):
DependencyProcessor.__init__(self, prop)
self.mapper._dependency_processors.append(DetectKeySwitch(prop)) | santisiri/popego | [
5,
2,
5,
1,
1476320366
] |
def process_dependencies(self, task, deplist, uowcommit, delete = False):
#print self.mapper.mapped_table.name + " " + self.key + " " + repr(len(deplist)) + " process_dep isdelete " + repr(delete) + " direction " + repr(self.direction)
if delete:
if self.post_update and not self.cascade.dele... | santisiri/popego | [
5,
2,
5,
1,
1476320366
] |
def _synchronize(self, state, child, associationrow, clearkeys, uowcommit):
if state is None or (not self.post_update and uowcommit.is_deleted(state)):
return
if clearkeys or child is None:
sync.clear(state, self.parent, self.prop.synchronize_pairs)
else:
sel... | santisiri/popego | [
5,
2,
5,
1,
1476320366
] |
def register_dependencies(self, uowcommit):
# many-to-many. create a "Stub" mapper to represent the
# "middle table" in the relationship. This stub mapper doesnt save
# or delete any objects, but just marks a dependency on the two
# related mappers. its dependency processor then popul... | santisiri/popego | [
5,
2,
5,
1,
1476320366
] |
def preprocess_dependencies(self, task, deplist, uowcommit, delete = False):
#print self.mapper.mapped_table.name + " " + self.key + " " + repr(len(deplist)) + " preprocess_dep isdelete " + repr(delete) + " direction " + repr(self.direction)
if not delete:
for state in deplist:
... | santisiri/popego | [
5,
2,
5,
1,
1476320366
] |
def _pks_changed(self, uowcommit, state):
return sync.source_changes(uowcommit, state, self.parent, self.prop.synchronize_pairs) | santisiri/popego | [
5,
2,
5,
1,
1476320366
] |
def __init__(self, *args, **kwargs):
super(AssociationDP, self).__init__(*args, **kwargs)
self.cascade.delete = True
self.cascade.delete_orphan = True | santisiri/popego | [
5,
2,
5,
1,
1476320366
] |
def __init__(self, parent, mapper, key):
self.mapper = mapper
self.base_mapper = self
self.class_ = mapper.class_
self._inheriting_mappers = [] | santisiri/popego | [
5,
2,
5,
1,
1476320366
] |
def _register_dependencies(self, uowcommit):
pass | santisiri/popego | [
5,
2,
5,
1,
1476320366
] |
def _delete_obj(self, *args, **kwargs):
pass | santisiri/popego | [
5,
2,
5,
1,
1476320366
] |
def __init__(self):
pass | rubendibattista/python-ransac-library | [
7,
3,
7,
3,
1431708514
] |
def min_points(self):
'''int: Minimum number of points needed to define the feature.''' | rubendibattista/python-ransac-library | [
7,
3,
7,
3,
1431708514
] |
def points_distance(self,points):
'''
This function implements a method to compute the distance
of points from the feature. | rubendibattista/python-ransac-library | [
7,
3,
7,
3,
1431708514
] |
def print_feature(self,num_points):
'''
This method returns an array of x,y coordinates for
points that are in the feature. | rubendibattista/python-ransac-library | [
7,
3,
7,
3,
1431708514
] |
def __init__(self,points):
self.radius,self.xc,self.yc = self.__gen(points) | rubendibattista/python-ransac-library | [
7,
3,
7,
3,
1431708514
] |
def __gen(self,points):
'''
Compute the radius and the center coordinates of a
circumference given three points | rubendibattista/python-ransac-library | [
7,
3,
7,
3,
1431708514
] |
def points_distance(self,points):
r'''
Compute the distance of the points from the feature | rubendibattista/python-ransac-library | [
7,
3,
7,
3,
1431708514
] |
def print_feature(self, num_points):
'''
This method returns an array of x,y coordinates for
points that are in the feature. | rubendibattista/python-ransac-library | [
7,
3,
7,
3,
1431708514
] |
def __init__(self,points):
self.a,self.k,self.b = self.__gen(points) | rubendibattista/python-ransac-library | [
7,
3,
7,
3,
1431708514
] |
def __gen(self,points):
'''
Compute the three parameters that univocally determine the
exponential curve | rubendibattista/python-ransac-library | [
7,
3,
7,
3,
1431708514
] |
def exponential(x,points):
''' Non linear system function to use
with :py:func:`scypy.optimize.root`
'''
aa = x[0]
nn = x[1]
bb = x[2] | rubendibattista/python-ransac-library | [
7,
3,
7,
3,
1431708514
] |
def points_distance(self,points):
r'''
Compute the distance of the points from the feature | rubendibattista/python-ransac-library | [
7,
3,
7,
3,
1431708514
] |
def print_feature(self, num_points, a,b):
'''
This method returns an array of x,y coordinates for
points that are in the feature in the interval [a,b]. | rubendibattista/python-ransac-library | [
7,
3,
7,
3,
1431708514
] |
def test_patch(self):
for (msg, orig, mod, expected_patch) in TEST_CASES:
self.assertEqual(expected_patch, makepatch(orig, mod), msg=msg) | MapofLife/MOL | [
23,
4,
23,
15,
1318277433
] |
def build_config_var(beta=False, external=False):
"""
Create the configuration key which will be used to locate
the base tiddlywiki file.
"""
base = 'base_tiddlywiki'
if external:
base += '_external'
if beta:
base += '_beta'
return base | TiddlySpace/tiddlyspace | [
105,
38,
105,
23,
1268688852
] |
def list_tiddlers(self, tiddlers):
"""
Override tiddlers.link so the location in noscript is to
/tiddlers.
"""
http_host, _ = determine_host(self.environ)
space_name = determine_space(self.environ, http_host)
if space_name:
recipe_name = determine_spac... | TiddlySpace/tiddlyspace | [
105,
38,
105,
23,
1268688852
] |
def baseURL():
if neuroptikon.runningFromSource:
basePath = os.path.join(neuroptikon.rootDir, 'documentation', 'build', 'Documentation')
else:
basePath = os.path.join(neuroptikon.rootDir, 'documentation') | JaneliaSciComp/Neuroptikon | [
9,
2,
9,
48,
1409685514
] |
def _construct_form(self, i, **kwargs):
# Need to override _construct_form to avoid calling to_python on an empty string PK value
if self.is_bound and i < self.initial_form_count():
pk_key = "%s-%s" % (self.add_prefix(i), self.model._meta.pk.name)
pk = self.data[pk_key]
... | torchbox/django-modelcluster | [
425,
59,
425,
24,
1391095565
] |
def transientmodelformset_factory(model, formset=BaseTransientModelFormSet, **kwargs):
return modelformset_factory(model, formset=formset, **kwargs) | torchbox/django-modelcluster | [
425,
59,
425,
24,
1391095565
] |
def __init__(self, data=None, files=None, instance=None, queryset=None, **kwargs):
if instance is None:
self.instance = self.fk.remote_field.model()
else:
self.instance = instance
self.rel_name = ForeignObjectRel(self.fk, self.fk.remote_field.model, related_name=self.fk.... | torchbox/django-modelcluster | [
425,
59,
425,
24,
1391095565
] |
def clean(self, *args, **kwargs):
self.validate_unique()
return super(BaseChildFormSet, self).clean(*args, **kwargs) | torchbox/django-modelcluster | [
425,
59,
425,
24,
1391095565
] |
def childformset_factory(
parent_model, model, form=ModelForm,
formset=BaseChildFormSet, fk_name=None, fields=None, exclude=None,
extra=3, can_order=False, can_delete=True, max_num=None, validate_max=False,
formfield_callback=None, widgets=None, min_num=None, validate_min=False | torchbox/django-modelcluster | [
425,
59,
425,
24,
1391095565
] |
def __init__(self, options=None):
super(ClusterFormOptions, self).__init__(options=options)
self.formsets = getattr(options, 'formsets', None)
self.exclude_formsets = getattr(options, 'exclude_formsets', None) | torchbox/django-modelcluster | [
425,
59,
425,
24,
1391095565
] |
def child_form(cls):
return ClusterForm | torchbox/django-modelcluster | [
425,
59,
425,
24,
1391095565
] |
def __init__(self, data=None, files=None, instance=None, prefix=None, **kwargs):
super(ClusterForm, self).__init__(data, files, instance=instance, prefix=prefix, **kwargs)
self.formsets = {}
for rel_name, formset_class in self.__class__.formsets.items():
if prefix:
f... | torchbox/django-modelcluster | [
425,
59,
425,
24,
1391095565
] |
def is_valid(self):
form_is_valid = super(ClusterForm, self).is_valid()
formsets_are_valid = all(formset.is_valid() for formset in self._posted_formsets)
return form_is_valid and formsets_are_valid | torchbox/django-modelcluster | [
425,
59,
425,
24,
1391095565
] |
def media(self):
media = super(ClusterForm, self).media
for formset in self.formsets.values():
media = media + formset.media
return media | torchbox/django-modelcluster | [
425,
59,
425,
24,
1391095565
] |
def format_excel(writer, df_size):
""" Add Excel specific formatting to the workbook
df_size is a tuple representing the size of the dataframe - typically called
by df.shape -> (20,3)
"""
# Get the workbook and the summary sheet so we can add the formatting
workbook = writer.book
worksheet =... | chris1610/pbpython | [
1894,
986,
1894,
14,
1431396080
] |
def daemonize():
"""
http://code.activestate.com/recipes/278731-creating-a-daemon-the-python-way/
http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/
"""
try:
pid = os.fork() # Fork #1
if pid > 0:
sys.exit(0) # Exit first parent
except OSErro... | erigones/Ludolph | [
39,
6,
39,
2,
1370966024
] |
def load_config(fp, reopen=False):
config = RawConfigParser()
if reopen:
fp = open(fp.name)
try: # config.readfp() is Deprecated since python 3.2
# noinspection PyDeprecation
read_file = config.readfp
except AttributeError:
read_file = c... | erigones/Ludolph | [
39,
6,
39,
2,
1370966024
] |
def log_except_hook(*exc_info):
logger.critical('Unhandled exception!', exc_info=exc_info) | erigones/Ludolph | [
39,
6,
39,
2,
1370966024
] |
def load_plugins(config, reinit=False):
plugins = []
for config_section in config.sections():
config_section = config_section.strip()
if config_section in config_base_sections:
continue
# Parse other possible imports
parsed_plugin = conf... | erigones/Ludolph | [
39,
6,
39,
2,
1370966024
] |
def sighup(signalnum, handler):
if xmpp.reloading:
logger.warning('Reload already in progress')
else:
xmpp.reloading = True
try:
config = load_config(cfg_fp, reopen=True)
logger.info('Reloaded configuration ... | erigones/Ludolph | [
39,
6,
39,
2,
1370966024
] |
def create(kernel):
result = Creature()
result.template = "object/mobile/shared_dressed_rebel_brigadier_general_sullustan_male.iff"
result.attribute_template_id = 9
result.stfName("npc_name","sullustan_base_male") | anhstudios/swganh | [
62,
37,
62,
37,
1297996365
] |
def create(kernel):
result = Creature()
result.template = "object/creature/npc/droid/crafted/shared_cll_8_binary_load_lifter_advanced.iff"
result.attribute_template_id = 3
result.stfName("droid_name","cll_8_binary_load_lifter_crafted_advanced") | anhstudios/swganh | [
62,
37,
62,
37,
1297996365
] |
def test_age_filter():
age = 22
search_fetchable = SearchFetchable(gentation='everybody',
minimum_age=age, maximum_age=age)
for profile in search_fetchable[:5]:
assert profile.age == age | IvanMalison/okcupyd | [
105,
18,
105,
24,
1411441891
] |
def test_count_variable(request):
profiles = search(gentation='everybody', count=14)
assert len(profiles) == 14
for profile in profiles:
profile.username
profile.age
profile.location
profile.match_percentage
profile.enemy_percentage
profile.id
profile... | IvanMalison/okcupyd | [
105,
18,
105,
24,
1411441891
] |
def test_location_filter():
session = Session.login()
location_cache = LocationQueryCache(session)
location = 'Portland, OR'
search_fetchable = SearchFetchable(location=location, location_cache=location_cache, radius=1)
for profile in search_fetchable[:5]:
assert profile.location == 'Portlan... | IvanMalison/okcupyd | [
105,
18,
105,
24,
1411441891
] |
def test_search_function():
profile, = search(count=1)
assert isinstance(profile, Profile)
profile.username
profile.age
profile.location
profile.match_percentage
profile.enemy_percentage
profile.id
profile.rating
profile.contacted | IvanMalison/okcupyd | [
105,
18,
105,
24,
1411441891
] |
def test_search_fetchable_iter():
search_fetchable = SearchFetchable(gentation='everybody',
religion='buddhist', age_min=25, age_max=25,
location='new york, ny', keywords='bicycle')
for count, profile in enumerate(search_fetchable):
... | IvanMalison/okcupyd | [
105,
18,
105,
24,
1411441891
] |
def test_easy_search_filters():
session = Session.login()
query_test_pairs = [# ('bodytype', maps.bodytype),
# TODO(@IvanMalison) this is an alist feature,
# so it can't be tested for now.
('drugs', maps.drugs), ('smokes', maps.smokes),
... | IvanMalison/okcupyd | [
105,
18,
105,
24,
1411441891
] |
def test_children_filter():
session = Session.login()
profile = SearchFetchable(session, wants_kids="wants kids", count=1)[0]
assert "wants" in profile.details.children.lower()
profile = SearchFetchable(session, has_kids=["has kids"],
wants_kids="doesn't want kids",
... | IvanMalison/okcupyd | [
105,
18,
105,
24,
1411441891
] |
def test_pets_queries():
session = Session.login()
profile = SearchFetchable(session, cats=['dislikes cats', 'likes cats'],
count=1)[0]
assert 'likes cats' in profile.details.pets.lower()
profile = SearchFetchable(session, dogs='likes dogs', cats='has cats', count=1)[0]
... | IvanMalison/okcupyd | [
105,
18,
105,
24,
1411441891
] |
def test_height_filter():
session = Session.login()
profile = SearchFetchable(session, height_min='5\'6"', height_max='5\'6"',
gentation='girls who like guys', radius=25, count=1)[0]
match = magicnumbers.imperial_re.search(profile.details.height)
assert int(match.group(1)) ... | IvanMalison/okcupyd | [
105,
18,
105,
24,
1411441891
] |
def test_language_filter():
session = Session.login()
profile = SearchFetchable(session, language='french', count=1)[0]
assert 'french' in [language_info[0].lower()
for language_info in profile.details.languages]
profile = SearchFetchable(session, language='Afrikaans', count=1)[... | IvanMalison/okcupyd | [
105,
18,
105,
24,
1411441891
] |
def test_attractiveness_filter():
session = Session.login()
profile = SearchFetchable(session, attractiveness_min=4000,
attractiveness_max=6000, count=1)[0]
assert profile.attractiveness > 4000
assert profile.attractiveness < 6000 | IvanMalison/okcupyd | [
105,
18,
105,
24,
1411441891
] |
def test_question_filter():
user = User()
user_question = user.questions.somewhat_important[0]
for profile in user.search(question=user_question)[:5]:
question = profile.find_question(user_question.id)
assert question.their_answer_matches | IvanMalison/okcupyd | [
105,
18,
105,
24,
1411441891
] |
def test_question_filter_with_custom_answers():
user = User()
user_question = user.questions.somewhat_important[1]
unacceptable_answers = [answer_option.id
for answer_option in user_question.answer_options
if not answer_option.is_match]
for profile... | IvanMalison/okcupyd | [
105,
18,
105,
24,
1411441891
] |
def test_question_count_filter():
user = User()
for profile in user.search(question_count_min=250)[:5]:
assert profile.questions[249] | IvanMalison/okcupyd | [
105,
18,
105,
24,
1411441891
] |
def to_bytes(string):
"""
Converts the given string into bytes
"""
# pylint: disable=E0602
if type(string) is unicode:
return str(string)
return string | CloudI/CloudI | [
384,
53,
384,
4,
1251785476
] |
def to_bytes(string):
"""
Converts the given string into bytes
"""
if type(string) is bytes:
return string
return bytes(string, "UTF-8") | CloudI/CloudI | [
384,
53,
384,
4,
1251785476
] |
def is_enum(obj):
"""
Checks if an object is from an enumeration class
:param obj: Object to test
:return: True if the object is an enumeration item
"""
return isinstance(obj, enum.Enum) | CloudI/CloudI | [
384,
53,
384,
4,
1251785476
] |
def is_enum(_):
"""
Before Python 3.4, enumerations didn't exist.
:param _: Object to test
:return: Always False
"""
return False | CloudI/CloudI | [
384,
53,
384,
4,
1251785476
] |
def create(kernel):
result = Tangible()
result.template = "object/tangible/scout/trap/shared_trap_webber.iff"
result.attribute_template_id = -1
result.stfName("item_n","trap_webber") | anhstudios/swganh | [
62,
37,
62,
37,
1297996365
] |
def create(kernel):
result = Tangible()
result.template = "object/tangible/wearables/ithorian/shared_ith_shirt_s09.iff"
result.attribute_template_id = 11
result.stfName("wearables_name","ith_shirt_s09") | anhstudios/swganh | [
62,
37,
62,
37,
1297996365
] |
def __init__(self, editwin):
self.editwin = editwin
# Provide instance variables referenced by Debugger
# XXX This should be done differently
self.flist = self.editwin.flist
self.root = self.editwin.root | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def check_module_event(self, event):
filename = self.getfilename()
if not filename:
return 'break'
if not self.checksyntax(filename):
return 'break'
if not self.tabnanny(filename):
return 'break' | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def tabnanny(self, filename):
f = open(filename, 'r')
try:
tabnanny.process_tokens(tokenize.generate_tokens(f.readline))
except tokenize.TokenError, msg:
msgtxt, (lineno, start) = msg
self.editwin.gotoline(lineno)
self.errorbox("Tabnanny Tok... | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def checksyntax(self, filename):
self.shell = shell = self.flist.open_shell()
saved_stream = shell.get_warning_stream()
shell.set_warning_stream(shell.stderr)
f = open(filename, 'r')
source = f.read()
f.close()
if '\r' in source:
source = re.su... | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def colorize_syntax_error(self, msg, lineno, offset):
text = self.editwin.text
pos = "0.0 + %d lines + %d chars" % (lineno-1, offset-1)
text.tag_add("ERROR", pos)
char = text.get(pos)
if char and char in IDENTCHARS:
text.tag_add("ERROR", pos + " wordstart", pos)... | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def run_module_event(self, event):
"""Run the module after setting up the environment. | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def getfilename(self):
"""Get source filename. If not saved, offer to save (or create) file | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def ask_save_dialog(self):
msg = "Source Must Be Saved\n" + 5*' ' + "OK to Save?"
mb = tkMessageBox.Message(title="Save Before Run or Check",
message=msg,
icon=tkMessageBox.QUESTION,
type=tkMessage... | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def validate(self):
self._assignment = None
if self.is_new():
if self.assigned_by == self.allocated_to:
assignment_message = frappe._("{0} self assigned this task: {1}").format(get_fullname(self.assigned_by), self.description)
else:
assignment_message = frappe._("{0} assigned {1}: {2}").format(get_fu... | frappe/frappe | [
4495,
2418,
4495,
1493,
1307520856
] |
def on_trash(self):
self.delete_communication_links()
self.update_in_reference() | frappe/frappe | [
4495,
2418,
4495,
1493,
1307520856
] |
def delete_communication_links(self):
# unlink todo from linked comments
return frappe.db.delete("Communication Link", {
"link_doctype": self.doctype,
"link_name": self.name
}) | frappe/frappe | [
4495,
2418,
4495,
1493,
1307520856
] |
def get_owners(cls, filters=None):
"""Returns list of owners after applying filters on todo's.
"""
rows = frappe.get_all(cls.DocType, filters=filters or {}, fields=['allocated_to'])
return [parse_addr(row.allocated_to)[1] for row in rows if row.allocated_to] | frappe/frappe | [
4495,
2418,
4495,
1493,
1307520856
] |
def on_doctype_update():
frappe.db.add_index("ToDo", ["reference_type", "reference_name"]) | frappe/frappe | [
4495,
2418,
4495,
1493,
1307520856
] |
def has_permission(doc, ptype="read", user=None):
user = user or frappe.session.user
todo_roles = frappe.permissions.get_doctype_roles('ToDo', ptype)
if 'All' in todo_roles:
todo_roles.remove('All')
if any(check in todo_roles for check in frappe.get_roles(user)):
return True
else:
return doc.allocated_to==u... | frappe/frappe | [
4495,
2418,
4495,
1493,
1307520856
] |
def _lines_to_dict(lines):
md = {}
errors = []
for line in lines:
# Skip a line if there is invalid value.
try:
line = line.decode("utf-8")
except UnicodeDecodeError as e:
errors.append("Invalid line '{}': {}".format(line, e))
continue
if... | oVirt/vdsm | [
129,
183,
129,
68,
1351274855
] |
def dump(lines):
md, errors = parse(lines)
if errors:
logging.warning(
"Invalid metadata found errors=%s", errors)
md["status"] = sc.VOL_STATUS_INVALID
else:
md["status"] = sc.VOL_STATUS_OK
# Do not include domain in dump output.
md.pop("domain", None)
retur... | oVirt/vdsm | [
129,
183,
129,
68,
1351274855
] |
def __init__(self, domain, image, parent, capacity, format, type, voltype,
disktype, description="", legality=sc.ILLEGAL_VOL, ctime=None,
generation=sc.DEFAULT_GENERATION,
sequence=sc.DEFAULT_SEQUENCE):
# Storage domain UUID
self.domain = domain
... | oVirt/vdsm | [
129,
183,
129,
68,
1351274855
] |
def from_lines(cls, lines):
'''
Instantiates a VolumeMetadata object from storage read bytes.
Args:
lines: list of key=value entries given as bytes read from storage
metadata section. "EOF" entry terminates parsing.
'''
metadata, errors = parse(lines)
... | oVirt/vdsm | [
129,
183,
129,
68,
1351274855
] |
def description(self):
return self._description | oVirt/vdsm | [
129,
183,
129,
68,
1351274855
] |
def description(self, desc):
self._description = self.validate_description(desc) | oVirt/vdsm | [
129,
183,
129,
68,
1351274855
] |
def capacity(self):
return self._capacity | oVirt/vdsm | [
129,
183,
129,
68,
1351274855
] |
def capacity(self, value):
self._capacity = self._validate_integer("capacity", value) | oVirt/vdsm | [
129,
183,
129,
68,
1351274855
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.