rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
self.parent.stopProduction(shutdownData.getInt("level")) | self._parent.stopProduction(shutdownData.getInt("level")) | def run(self): self.parent.logger.log(Log.DEBUG, "listening for shutdown event at %s s intervals" % self._pollintv) |
print( "error reading uncompressed AVI:" ) print( details ) | if DEBUG: print( "error reading uncompressed AVI:" ) if DEBUG: print( details ) | def __init__( self, filename, fmfmode=False ): self.fmfmode = fmfmode self.issbfmf = False |
if f0 is None: | if f0 is None or type(f0) != type(1): | def write_results_to_avi(movie,tracks,filename,f0=None,f1=None): nframes = len(tracks) if f0 is None: f0 = params.start_frame if f1 is None: f1 = nframes + params.start_frame - 1 f0 -= params.start_frame f1 -= params.start_frame f0 = max(0,min(nframes-1,f0)) f1 = max(0,min(nframes-1,f1)) nframes_write = f1-f0+1 # op... |
if f1 is None: f1 = nframes + params.start_frame - 1 | if f1 is None or type(f1) != type(1): f1 = nframes + params.start_frame - 1 | def write_results_to_avi(movie,tracks,filename,f0=None,f1=None): nframes = len(tracks) if f0 is None: f0 = params.start_frame if f1 is None: f1 = nframes + params.start_frame - 1 f0 -= params.start_frame f1 -= params.start_frame f0 = max(0,min(nframes-1,f0)) f1 = max(0,min(nframes-1,f1)) nframes_write = f1-f0+1 # op... |
for dataframe in tracks[early_frame:i+1]: | for f in range( early_frame, i+1 ): dataframe = tracks[f] | def write_avi_frame(movie,tracks,i,outstream): height = movie.get_height() width = movie.get_width() BYTESPERPIXEL = 3 bytesperframe = width*height*BYTESPERPIXEL if tracks is None: return if i >= len(tracks): return # global frame index j = params.start_frame + i # read in the video frame try: frame, last_timestamp... |
model_key = path.pop(0) | model_key = None if (len(path) > 0): model_key = path.pop(0) | def put(self, *_): """Does a REST put. '/<type>/<key>' -> completely replaces Model instance, returns key as plain text (200, 400, 404) """ |
return self.property_type.get_value_for_datastore(model) | value = self.property_type.get_value_for_datastore(model) if(value and (not isinstance(value, self.get_data_type()))): value = value.key() return value | def get_value(self, model): """Returns the key of the referenced model instance.""" return self.property_type.get_value_for_datastore(model) |
model = self.model_from_xml(doc.documentElement, model_name, model_handler, model_key, is_replace) | for model_el_key, model_el in model_els: models.append(self.model_from_xml(model_el, model_name, model_handler, model_el_key, is_replace)) | def update_impl(self, model_name, model_key, is_replace): """Actual implementation of all Model update methods. Creates/updates/replaces Model instances as specified. Writes the key of the modified Model as a plain text result. """ model_handler = self.get_model_handler(model_name) if(not model_handler): return |
model.put() | for model in models: model.put() if(not is_list): models = models[0] | def update_impl(self, model_name, model_key, is_replace): """Actual implementation of all Model update methods. Creates/updates/replaces Model instances as specified. Writes the key of the modified Model as a plain text result. """ model_handler = self.get_model_handler(model_name) if(not model_handler): return |
self.write_output(self.models_to_xml(model_name, model_handler, model)) | self.write_output(self.models_to_xml(model_name, model_handler, models)) | def update_impl(self, model_name, model_key, is_replace): """Actual implementation of all Model update methods. Creates/updates/replaces Model instances as specified. Writes the key of the modified Model as a plain text result. """ model_handler = self.get_model_handler(model_name) if(not model_handler): return |
self.write_output(self.keys_to_xml(model_handler, model)) | self.write_output(self.keys_to_xml(model_handler, models)) | def update_impl(self, model_name, model_key, is_replace): """Actual implementation of all Model update methods. Creates/updates/replaces Model instances as specified. Writes the key of the modified Model as a plain text result. """ model_handler = self.get_model_handler(model_name) if(not model_handler): return |
self.write_output(unicode(model.key())) | self.write_output(self.keys_to_text(models)) | def update_impl(self, model_name, model_key, is_replace): """Actual implementation of all Model update methods. Creates/updates/replaces Model instances as specified. Writes the key of the modified Model as a plain text result. """ model_handler = self.get_model_handler(model_name) if(not model_handler): return |
raise TypeError("wrong model name") | raise TypeError("wrong model name, found '%s', expected '%s'" % (model_el.nodeName, model_name)) | def model_from_xml(self, model_el, model_name, model_handler, key, is_replace): """Returns a model instance updated from the given model xml element.""" if(model_name != str(model_el.nodeName)): raise TypeError("wrong model name") |
def write_xml_value(self, model_el, model, blob_info_format): | def write_xml_value(self, model_el, model, blob_info_format, includeProps): | def write_xml_value(self, model_el, model, blob_info_format): """Appends the properties of the given instance as xml elements to the given model element.""" # write key property first self.write_xml_property(model_el, model, KEY_PROPERTY_NAME, self.key_handler, blob_info_format) |
self.write_xml_property(model_el, model, KEY_PROPERTY_NAME, self.key_handler, blob_info_format) | if((includeProps is None) or (KEY_PROPERTY_NAME in includeProps)): self.write_xml_property(model_el, model, KEY_PROPERTY_NAME, self.key_handler, blob_info_format) | def write_xml_value(self, model_el, model, blob_info_format): """Appends the properties of the given instance as xml elements to the given model element.""" # write key property first self.write_xml_property(model_el, model, KEY_PROPERTY_NAME, self.key_handler, blob_info_format) |
self.write_xml_property(model_el, model, prop_xml_name, prop_handler, blob_info_format) | if((includeProps is None) or (prop_xml_name in includeProps)): self.write_xml_property(model_el, model, prop_xml_name, prop_handler, blob_info_format) | def write_xml_value(self, model_el, model, blob_info_format): """Appends the properties of the given instance as xml elements to the given model element.""" # write key property first self.write_xml_property(model_el, model, KEY_PROPERTY_NAME, self.key_handler, blob_info_format) |
self.write_xml_property(model_el, model, prop_xml_name, DynamicPropertyHandler(prop_name), blob_info_format) | if((includeProps is None) or (prop_xml_name in includeProps)): self.write_xml_property(model_el, model, prop_xml_name, DynamicPropertyHandler(prop_name), blob_info_format) | def write_xml_value(self, model_el, model, blob_info_format): """Appends the properties of the given instance as xml elements to the given model element.""" # write key property first self.write_xml_property(model_el, model, KEY_PROPERTY_NAME, self.key_handler, blob_info_format) |
resp_type = self.get_query_param(QUERY_TYPE_PARAM, None) | resp_type = self.get_query_param(QUERY_TYPE_PARAM) | def update_impl(self, path, model_name, model_key, method_name, is_replace): """Actual implementation of all Model update methods. Creates/updates/replaces Model instances as specified. Writes the key of the modified Model as a plain text result. """ model_handler = self.get_model_handler(model_name, method_name) |
if((arg == QUERY_CALLBACK_PARAM) or (arg == QUERY_BLOBINFO_PARAM)): | if(arg in EXTRA_QUERY_PARAMS): | def get_all_impl(self, model_handler, list_props): """Actual implementation of REST query. Gets Model instances based on criteria specified in the query parameters. """ |
blob_info_format = self.get_query_param(QUERY_BLOBINFO_PARAM, QUERY_BLOBINFO_TYPE_KEY) | def models_to_xml(self, model_name, model_handler, models, list_props=None): """Returns a string of xml of the given models (may be list or single instance).""" impl = minidom.getDOMImplementation() blob_info_format = self.get_query_param(QUERY_BLOBINFO_PARAM, QUERY_BLOBINFO_TYPE_KEY) doc = None try: if isinstance(mode... | |
model_handler.write_xml_value(model_el, model, blob_info_format) | model_handler.write_xml_value(model_el, model, blob_info_format, includeProps) | def models_to_xml(self, model_name, model_handler, models, list_props=None): """Returns a string of xml of the given models (may be list or single instance).""" impl = minidom.getDOMImplementation() blob_info_format = self.get_query_param(QUERY_BLOBINFO_PARAM, QUERY_BLOBINFO_TYPE_KEY) doc = None try: if isinstance(mode... |
model_handler.write_xml_value(doc.documentElement, models, blob_info_format) | model_handler.write_xml_value(doc.documentElement, models, blob_info_format, includeProps) | def models_to_xml(self, model_name, model_handler, models, list_props=None): """Returns a string of xml of the given models (may be list or single instance).""" impl = minidom.getDOMImplementation() blob_info_format = self.get_query_param(QUERY_BLOBINFO_PARAM, QUERY_BLOBINFO_TYPE_KEY) doc = None try: if isinstance(mode... |
callback = self.get_query_param(QUERY_CALLBACK_PARAM, None) | callback = self.get_query_param(QUERY_CALLBACK_PARAM) | def write_output(self, out): """Writes the output to the response.""" if out: first_char = out[0] content_type = TEXT_CONTENT_TYPE out_suffix = None if(first_char == '{'): content_type = JSON_CONTENT_TYPE # check for json callback callback = self.get_query_param(QUERY_CALLBACK_PARAM, None) if callback: self.response.ou... |
for typ in [l[0] for l in listes.LISTE_TYPES]: | for typ in [l[0] for l in LISTE_TYPES]: | def detail_module(request): # récup visiteur v = request.session['v'] # utilisateur uid = request.GET['id'] try: u = Utilisateur.objects.get(id=uid) except Utilisateur.DoesNotExist: HttpResponseRedirect(reverse('v_home')) # module demandé id_mod = request.GET['mid'] try: m = Module.objects.get(id=id_mod) except Module.... |
self.save() | super(Echeance, self).save() | def delete(self, trash=True): if not self.trashed_at and trash: self.trashed_at = datetime.datetime.now() self.save() else: super(Echeance, self).delete() |
'staff': u.status==STAFF, | 'administrateur': u.status>COACH, | def liste_works(request, **kwargs): """View: list of assignments of this administrator's groups or users. Filters on group and cours.""" # préparation des paramètres # les clés de ce dictionnaire *doivent* être des chaînes params = dict(request.GET.items()) for key, value in params.items(): if not isinstance(key, str... |
'staff': v.status==STAFF, | 'administrateur': v.status>COACH, | def add_work(request): """View: adds an assignment for a groupe/cours. """ # récup visiteur v = request.session['v'] if request.method == 'POST': if 'c' in request.POST: # dernière étape, recup des valeurs et sauvegarde du devoir à rendre g = Groupe.objects.get(id=request.POST['g']) c = Cours.objects.get(id=request.POS... |
'staff': v.status==STAFF, | 'administrateur': v.status>COACH, | def maj_work(request): """View: change or delete assignment. """ # récup visiteur v = request.session['v'] if request.method == 'POST': if 'trash' in request.POST: # effacer l'échéance w = Work.objects.get(id=request.GET['id']) try: w.echeance = Echeance.objects.filter(groupe=w.groupe, cours=w.cours).latest('echeance')... |
'staff': u.status==STAFF, | 'administrateur': u.status>COACH, | def liste_echeances(request, **kwargs): """View: list of echeances of this administrator's groups or users. Filters on group and cours.""" # préparation des paramètres # les clés de ce dictionnaire *doivent* être des chaînes params = dict(request.GET.items()) for key, value in params.items(): if not isinstance(key, s... |
'staff': v.status==STAFF, | 'administrateur': v.status>COACH, | def add_echeance(request): """View: adds a deadline for user/group and course/module. """ # récup visiteur v = request.session['v'] if request.method == 'POST': if 'c' in request.POST: # dernière étape, recup des valeurs et sauvegarde de l'échéance g = Groupe.objects.get(id=request.POST['g']) uf = {} if request.POST['u... |
'staff': v.status==STAFF, | 'administrateur': v.status>COACH, | def maj_echeance(request): """View: updates or deletes a deadline for user/group and course/module. """ # récup visiteur v = request.session['v'] if request.method == 'POST': if 'trash' in request.POST: # effacer l'échéance e = Echeance.objects.get(id=request.GET['id']) e.delete() msg = _('This deadline has been delete... |
'staff': v.status==STAFF, | 'administrateur': v.status>COACH, | def log_utilisateur(request): """View: log des visites d'un utilisateur """ # récup visiteur v = request.session['v'] try: u = Utilisateur.objects.get(id=request.GET['id']) except Utilisateur.DoesNotExist: return HttpResponseRedirect(reverse('v_home')) if not u.groupe in v.groupes_list(): return HttpResponseRedirect(re... |
'staff': v.status==STAFF, | 'administrateur': v.status>COACH, | def logs(request): """View: log des visites """ # récup visiteur v = request.session['v'] us = Utilisateur.objects.filter(groupe__in=v.groupes_list()) logs = Log.objects.filter(utilisateur__in=us) v.lastw = datetime.datetime.now() request.session['v'] = v v.save() return list_detail.object_list( request, queryset=logs,... |
'staff': v.status==STAFF, | 'administrateur': v.status>COACH, | def detail_module(request): # récup visiteur v = request.session['v'] # utilisateur uid = request.GET['id'] try: u = Utilisateur.objects.get(id=uid) except Utilisateur.DoesNotExist: HttpResponseRedirect(reverse('v_home')) # module demandé id_mod = request.GET['mid'] try: m = Module.objects.get(id=id_mod) except Module.... |
'staff': v.status==STAFF, | 'administrateur': v.status>COACH, | def detail_utilisateur(request): """View: détails du travail d'un utilisateur """ # récup visiteur v = request.session['v'] try: u = Utilisateur.objects.get(id=request.GET['id']) except Utilisateur.DoesNotExist: return HttpResponseRedirect(reverse('v_home')) if not u.groupe in v.groupes_list(): return HttpResponseRedir... |
'staff': v.status==STAFF, | 'administrateur': v.status>COACH, | def profile_utilisateur_admin(request, utilisateur=None): """View: user's record for administrator. Administrator may update some fields : - group - first name - last name - email - valid till date - language """ # récup visiteur v = request.session['v'] # test visiteur est admin du groupe de cet utilisateur try: u = ... |
'staff': v.status==STAFF, | 'administrateur': v.status>COACH, | def liste_utilisateurs(request, **kwargs): """ View: list of users coached or administered by visitor. Returns a table of : - group - login - last name - first name - language and other fields related to status of visitor (admin or coach). Sortable on any field(s), filters on group and language.""" # v = utilisateur ... |
'staff': v.status==STAFF, | 'administrateur': v.status>COACH, | def liste_clients(request): """View: stats by client for staff Returns a table of: - client - group - # of courses for this group - # of modules in this group courses - # of logins for this client-group - # of users who worked yesterday """ v = request.session['v'] # préparation des paramètres # les clés de ce diction... |
'staff': v.status==STAFF, | 'administrateur': v.status>COACH, | def create_logins(request): """Creation de logins à partir d'un fichier csv. """ import os import time import StringIO import unicodedata import random import sha #from mailer.sender import send_mail from utils import send_mail v = request.session['v'] if request.method == 'POST': if 'fsource' in request.POST: g = Grou... |
'admin': v.status, | 'administrateur': v.status>COACH, | def menu(request): """View: displays administrator's menu. """ # v = utilisateur courant v = request.session['v'] return render_to_response('coaching/menu.html', {'visiteur': v.prenom_nom(), 'client': v.groupe.client, 'here': 'admin', 'admin': v.status, 'staff': v.status==STAFF }) |
'staff': v.status==STAFF, | 'administrateur': v.status>COACH, | def send_email(request): """View: sends an email to user or group. """ #from mailer.sender import send_mail #from utils import send_mail v = request.session['v'] if 'id' in request.GET: # verif v est coach du groupe des id for id in request.GET.getlist('id'): try: u = Utilisateur.objects.get(pk=id) except Utilisateur.D... |
for c in self.groupe.cours_set.all(): | for c in self.groupe.cours.all(): | def save(self, force_insert=False, force_update=False): if not self.groupe: u = self.utilisateur self.groupe = u.groupe if not self.cours: # recherche du cours à partir du groupe et du module for c in self.groupe.cours_set.all(): if self.module in [mc.module for mc in c.modulecours_set.all()]: self.cours = c break # on... |
'admin': v.status, | 'staff': v.status==STAFF, | def profile(request): # récup visiteur v = request.session['v'] if request.method == 'POST': f = UtilisateurForm(request.POST) if f.is_valid(): v.email = f.cleaned_data['email'] v.langue = f.cleaned_data['langue'] request.session['django_language'] = v.langue if f.cleaned_data['newpassword2']: v.password = f.cleaned_da... |
'here': 'dashboard', | 'staff': u.status==STAFF, | def module(request, slug=None): """View: return user's dashboard for given module""" # récup visiteur u = request.session['v'] # module demandé #try: # m = Module.objects.get(slug=slug) #except Module.DoesNotExist: # HttpResponseRedirect('/tdb/') m = get_object_or_404(Module, slug=slug) # recup cours auquel le mo... |
'here': 'dashboard', | 'staff': v.status==STAFF, | def support(request, slug=None, **kwargs): """View: html course content. The new_visitor_may_see_module decorator checks that: - the module is part of at least one course the visitor's group is subscribed to Returns the html content embedded in user's template. """ # on a besoin de la langue dans laquelle afficher le ... |
return not self.__eq__(self, other) | return not self.__eq__(other) | def __ne__(self, other): return not self.__eq__(self, other) |
self.Show(True) | def status_bar_callback(grapharea): s = "Number of nodes: " + str(len(grapharea.graph.nodes)) + "." if hasattr(grapharea, 'nomoregraphs') and grapharea.nomoregraphs: s += " No more graphs." self.SetStatusText(s) | |
with file(getcwd() + "/state.dat", 'rw') as statefile: | s = getcwd() + "/state.dat" try: f = open(s, 'r') except IOError: f = file(s, 'w') finally: f.close() with file(s, 'r') as statefile: | def load_state(self): with file(getcwd() + "/state.dat", 'rw') as statefile: c = statefile.read() if not c == '': statefile.seek(0) self.state = pickle.load(statefile) else: self.state = State() if self.state.color_scheme == 'black': colors.set_color_scheme_black() elif self.state.color_scheme == 'white': colors.set_c... |
dlg = wx.FileDialog(self, "Choose a file", self.state.rule_dir, "", "*.*", wx.OPEN) | dlg = wx.FileDialog(self, "Open Rule Set", self.state.rule_dir, "", "*.*", wx.OPEN) | def OnLoadRuleSet(self, event): dlg = wx.FileDialog(self, "Choose a file", self.state.rule_dir, "", "*.*", wx.OPEN) if dlg.ShowModal() == wx.ID_OK: name = dlg.GetPath() rulename = dlg.GetFilename() self.state.rule_dir = name[:name.index(rulename) - 1] suffix = name[-3:] if not (suffix == 'trs' or suffix == 'xml'): prin... |
dlg = wx.FileDialog(self, "Choose a file", self.state.save_dir, "", "*.*", wx.SAVE) | dlg = wx.FileDialog(self, "Save Screenshot", self.state.save_dir, "", "*.*", wx.SAVE) | def OnScreenshot(self, event): dlg = wx.FileDialog(self, "Choose a file", self.state.save_dir, "", "*.*", wx.SAVE) if dlg.ShowModal() == wx.ID_OK: name = dlg.GetPath() filename = dlg.GetFilename() self.state.save_dir = name[:name.index(filename) - 1] self.drawing.export_canvas(name) self.save_state() |
class MyRoutesModule(snakeroutes.RoutesModule): | class MyRoutesModule(snakeweb.RoutesModule): | def setup(self): super(TestRoutesModuleSetup, self).setup() |
snakeroutes.RoutesBinder.return_value) | snakeweb.RoutesBinder.return_value) | def test_configure_mapper_is_called_with_a_mapper(self): assert self.module.configure_mapper.calls('()', snakeroutes.RoutesBinder.return_value) |
assert snakeroutes.routes.Mapper.calls() | assert snakeweb.routes.Mapper.calls() | def test_real_routes_mapper_was_created(self): assert snakeroutes.routes.Mapper.calls() |
class TestRoutesModuleIsAbstract(DingusTestCase(snakeroutes.RoutesModule)): | class TestRoutesModuleIsAbstract(DingusTestCase(snakeweb.RoutesModule)): | def test_real_routes_mapper_was_created(self): assert snakeroutes.routes.Mapper.calls() |
self.module = snakeroutes.RoutesModule() | self.module = snakeweb.RoutesModule() | def setup(self): super(TestRoutesModuleIsAbstract, self).setup() self.module = snakeroutes.RoutesModule() |
class BaseTestRoutesBinder(DingusTestCase(snakeroutes.RoutesBinder)): | class BaseTestRoutesBinder(DingusTestCase(snakeweb.RoutesBinder)): | def test_configure_mapper_is_not_implemented(self): self.module.configure(Dingus()) |
self.binder = snakeroutes.RoutesBinder(self.routes_mapper, self.annotation) | self.binder = snakeweb.RoutesBinder(self.routes_mapper, self.annotation) | def setup(self): super(BaseTestRoutesBinder, self).setup() self.routes_mapper = Dingus() self.annotation = Dingus() self.binder = snakeroutes.RoutesBinder(self.routes_mapper, self.annotation) |
if not binder: binder = Binder(self) self._binder = binder | def __init__(self, modules, binder=None, stage=None): if not hasattr(modules, '__iter__'): modules = [modules] | |
def print_missing_sites(nexus_obj, action, value_dict): | def print_missing_sites(nexus_obj): | def print_missing_sites(nexus_obj, action, value_dict): """ Prints out counts of the number of missing/gap sites in a nexus. (Wrapper around `count_missings`) :param nexus_obj: A `NexusReader` instance :type nexus_obj: NexusReader """ missings = count_missing_sites(nexus_obj) print ("Missing data in %s" % nexus_obj.f... |
nexus.write_to_file(new) print "New nexus with %d trees written to %s" % (nexus.trees.ntrees, new) | nexus.write_to_file(newnexus) print "New nexus with %d trees written to %s" % (nexus.trees.ntrees, newnexus) | def run_random(num_trees, nexus_obj): """ Returns a specified number (`num_trees`) of random trees from the nexus file. :param num_trees: The number of trees to resample :type num_trees: Integer :param nexus_obj: A `NexusReader` instance :type nexus_obj: NexusReader :return: A NexusReader instance. :raises Assertio... |
charpos = 1 for nex in nexuslist: | charpos = 0 for nex_id, nex in enumerate(nexuslist, 1): | def combine_nexuses(nexuslist): """ Combines a list of NexusReader instances into a single nexus :param nexuslist: A list of NexusReader instances :type nexuslist: List :return: A NexusWriter instance :raises TypeError: if nexuslist is not a list of NexusReader instances :raises IOError: if unable to read an file in... |
raise NexusFormatException("Warning: %s has no data block" % nex.filename) | raise NexusFormatException("Error: %s has no data block" % nex.filename) | def combine_nexuses(nexuslist): """ Combines a list of NexusReader instances into a single nexus :param nexuslist: A list of NexusReader instances :type nexuslist: List :return: A NexusWriter instance :raises TypeError: if nexuslist is not a list of NexusReader instances :raises IOError: if unable to read an file in... |
for site, data in nex.data.characters.items(): charpos += site | for site_idx, site in enumerate(sorted(nex.data.characters), 0): data = nex.data.characters.get(site) charpos += 1 charlabel = nex.data.charlabels.get(site_idx, site_idx + 1) if nex.filename == '<String>': label = '%s.%s' % (str(nex_id), charlabel) else: label = '%s.%s' % (nex.filename, charlabel) | def combine_nexuses(nexuslist): """ Combines a list of NexusReader instances into a single nexus :param nexuslist: A list of NexusReader instances :type nexuslist: List :return: A NexusWriter instance :raises TypeError: if nexuslist is not a list of NexusReader instances :raises IOError: if unable to read an file in... |
out.add(taxon, charpos, value) charpos += 1 | out.add(taxon, label, value) | def combine_nexuses(nexuslist): """ Combines a list of NexusReader instances into a single nexus :param nexuslist: A list of NexusReader instances :type nexuslist: List :return: A NexusWriter instance :raises TypeError: if nexuslist is not a list of NexusReader instances :raises IOError: if unable to read an file in... |
is_dimensions = re.compile(r"""dimensions ntax=(\d+)""", re.IGNORECASE) | is_dimensions = re.compile(r"""dimensions\s*ntax=\s*(\d+)""", re.IGNORECASE) | def write(self): """ Generates a string containing a generic nexus block for this data. :return: String """ return "\n".join(self.block) |
self.taxa.append(line) | self.taxa.append(line.strip(";")) | def parse(self, data): """ Parses a `taxa` nexus block from `data`. :param data: nexus block data :type data: string :return: None """ super(TaxaHandler, self).parse(data) in_taxlabel_block = False for line in data: line = self.remove_comments(line).strip() line = QUOTED_PATTERN.sub('\\1', line) if self.is_dimensions... |
if nex.filename == '<String>': label = '%s.%s' % (str(nex_id), charlabel) else: label = '%s.%s' % (nex.filename, charlabel) | label = '%s.%s' % (str(nex_id), charlabel) | def combine_nexuses(nexuslist): """ Combines a list of NexusReader instances into a single nexus :param nexuslist: A list of NexusReader instances :type nexuslist: List :return: A NexusWriter instance :raises TypeError: if nexuslist is not a list of NexusReader instances :raises IOError: if unable to read an file in... |
parser.add_option("-u", "--removeuniques", dest="removeuniques", action="store_true", default=False, help="Remove the unique characters") | def binarise(nexus_obj, one_nexus_per_block=False): """ Returns a binary variant of the given `nexus_obj`. If `one_nexus_per_block` then we return a list of NexusWriter instances. :param nexus_obj: A `NexusReader` instance :type nexus_obj: NexusReader :param one_nexus_per_block: Whether to return a single NexusWriter... | |
if options.removeuniques: print "NOT IMPLEMENTED" | def binarise(nexus_obj, one_nexus_per_block=False): """ Returns a binary variant of the given `nexus_obj`. If `one_nexus_per_block` then we return a list of NexusWriter instances. :param nexus_obj: A `NexusReader` instance :type nexus_obj: NexusReader :param one_nexus_per_block: Whether to return a single NexusWriter... | |
line = '' | line = bytearray() | def readline(self, size=None, eol='\n'): """read a line which is terminated with end-of-line (eol) character ('\n' by default) or until timeout""" line = '' while 1: c = self.read(1) if c: line += c # not very efficient but lines are usually not that long if c == eol: break if size is not None and len(line) >= size: ... |
for fd, event in poll.poll(self._timeout): | for fd, event in poll.poll(self._timeout*1000): | def read(self, size=1): """Read size bytes from the serial port. If a timeout is set it may return less characters as requested. With no timeout it will block until the requested number of bytes is read.""" if self.fd is None: raise portNotOpenError read = bytearray() poll = select.poll() poll.register(self.fd, select.... |
dsrdtr=None, | dsrdtr=False, | def __init__(self, port = None, # number of device, numbering starts at # zero. if everything fails, the user # can specify a device string, note # that this isn't portable anymore # port will be opened if one is specified baudrate=9600, # baud rate bytesize=EIGHTBITS, # number of data bits parity=... |
fcntl.fcntl(self.fd, FCNTL.F_SETFL, FCNTL.O_NONBLOCK) | fcntl.fcntl(self.fd, FCNTL.F_SETFL, os.O_NONBLOCK) | def nonblocking(self): """internal - not portable!""" if self.fd is None: raise portNotOpenError fcntl.fcntl(self.fd, FCNTL.F_SETFL, FCNTL.O_NONBLOCK) |
_IOC_SIZEMASK = (1L << _IOC_SIZEBITS ) - 1 | _IOC_SIZEMASK = (1 << _IOC_SIZEBITS ) - 1 | def _IOW(type,nr,size): return _IOC(_IOC_WRITE, type, nr, sizeof(size)) |
_IOC_WRITE = 1L _IOC_READ = -2L _IOC_INOUT = -1L | _IOC_WRITE = 1 _IOC_READ = -2 _IOC_INOUT = -1 | def _IOW(type,nr,size): return _IOC(_IOC_WRITE, type, nr, sizeof(size)) |
_IOC_WRITE = 1L _IOC_READ = 2L _IOC_INOUT = 3L | _IOC_WRITE = 1 _IOC_READ = 2 _IOC_INOUT = 3 | def _IOW(type,nr,size): return _IOC(_IOC_WRITE, type, nr, sizeof(size)) |
err = win32.ReadFile(self.hComPort, buf, size, ctypes.byref(rc), ctypes.byref(self._overlappedRead)) | err = win32.ReadFile(self.hComPort, buf, n, ctypes.byref(rc), ctypes.byref(self._overlappedRead)) | def read(self, size=1): """Read size bytes from the serial port. If a timeout is set it may return less characters as requested. With no timeout it will block until the requested number of bytes is read.""" if not self.hComPort: raise portNotOpenError if size > 0: win32.ResetEvent(self._overlappedRead.hEvent) flags = w... |
bytes_0to255 = bytes([range(256)]) | bytes_0to255 = bytes(range(256)) | def data(string): return bytes(string, 'latin1') |
def readlines(self, sizehint=None, eol='\n'): | def readlines(self, sizehint=None, eol=LF): | def readlines(self, sizehint=None, eol='\n'): """read a list of lines, until timeout. sizehint is ignored.""" if self.timeout is None: raise ValueError("Serial port MUST have enabled timeout for this function!") lines = [] while True: line = self.readline(eol=eol) if line: lines.append(line) if line[-1] != eol: # wa... |
ret = self.__addFilesToThreadPool( filesToTransfer, outputDict ) | ret = self.__addFilesToThreadPool( filesToTransfer, transferPath ) | def checkForTransfers( self ): """ Check for transfers to do and start them """ result = self.getDefinedTransferPaths() if not result[ 'OK' ]: return result tPaths = result[ 'Value' ] for name in tPaths: transferPath = tPaths[ name ] filesToTransfer = self.getOutgoingFiles( tPaths[ name ] ) ret = self.__addFilesToThrea... |
if type( value ) not in ( types.DictType, types.TupleType ): | if type( value ) not in ( types.ListType, types.TupleType ): | def getHistoryValues( self, averageBucket, selDict = {}, fields2Get = False, timespan = 0 ): try: timespan = max( 0, int( timespan ) ) except: return S_ERROR( "Timespan has to be an integer" ) |
value = [ self._escapeString( str( v ) )[ 'Value' ] for v in values ] | value = [ self._escapeString( str( v ) )[ 'Value' ] for v in value ] | def getHistoryValues( self, averageBucket, selDict = {}, fields2Get = False, timespan = 0 ): try: timespan = max( 0, int( timespan ) ) except: return S_ERROR( "Timespan has to be an integer" ) |
firstValues = [] lastValues = [] | prevValues = False | def getHistoryValues( self, averageBucket, selDict = {}, fields2Get = False, timespan = 0 ): try: timespan = max( 0, int( timespan ) ) except: return S_ERROR( "Timespan has to be an integer" ) |
if lastValues and firstValues: | if prevValues: | def getHistoryValues( self, averageBucket, selDict = {}, fields2Get = False, timespan = 0 ): try: timespan = max( 0, int( timespan ) ) except: return S_ERROR( "Timespan has to be an integer" ) |
for i in range( len( lastValues ) ): instValues.append( lastValues[ i ] - firstValues[ i ] ) | for i in range( len( prevValues ) ): instValues.append( prevValues[ i ] ) | def getHistoryValues( self, averageBucket, selDict = {}, fields2Get = False, timespan = 0 ): try: timespan = max( 0, int( timespan ) ) except: return S_ERROR( "Timespan has to be an integer" ) |
lastValues = [] | prevValues = [] | def getHistoryValues( self, averageBucket, selDict = {}, fields2Get = False, timespan = 0 ): try: timespan = max( 0, int( timespan ) ) except: return S_ERROR( "Timespan has to be an integer" ) |
lastValues.append( row[i] ) | prevValues.append( row[i] ) | def getHistoryValues( self, averageBucket, selDict = {}, fields2Get = False, timespan = 0 ): try: timespan = max( 0, int( timespan ) ) except: return S_ERROR( "Timespan has to be an integer" ) |
lastValues.append( 0 ) if not firstValues: for i in range( len ( row ) ): if i in requireExtension: firstValues.append( row[i] ) else: firstValues.append( 0 ) | prevValues.append( 0 ) | def getHistoryValues( self, averageBucket, selDict = {}, fields2Get = False, timespan = 0 ): try: timespan = max( 0, int( timespan ) ) except: return S_ERROR( "Timespan has to be an integer" ) |
instValues.append( row[ i ] - firstValues[ i ] ) | instValues.append( row[ i ] ) | def getHistoryValues( self, averageBucket, selDict = {}, fields2Get = False, timespan = 0 ): try: timespan = max( 0, int( timespan ) ) except: return S_ERROR( "Timespan has to be an integer" ) |
finalData[-1].extend( sumData[ date ] ) | values = sumData[ date ] for i in range( len( values ) ): finalData[-1].append( max( 0, values[i] - firstValues[i] ) ) | def getHistoryValues( self, averageBucket, selDict = {}, fields2Get = False, timespan = 0 ): try: timespan = max( 0, int( timespan ) ) except: return S_ERROR( "Timespan has to be an integer" ) |
sqlCond.append( "TIMESTAMPDIFF( SECOND, Update, UTC_TIMESTAMP() ) > %d" % timespan ) | sqlCond.append( "TIMESTAMPDIFF( SECOND, `Update`, UTC_TIMESTAMP() ) > %d" % timespan ) | def getAverageHistoryValues( self, averageBucket, selDict = {}, fields2Get = False, timespan = 0 ): try: timespan = max( 0, int( timespan ) ) except: return S_ERROR( "Timespan has to be an integer" ) |
return DIRAC.S_ERROR( 'Image "%s" in DB but it does not match', imageName ) | return DIRAC.S_ERROR( 'Image "%s" in DB but it does not match' % imageName ) | def __getImageID( self, imageName ): """ For a given imageName return corresponding ID Will insert the image in New Status if it does not exits """ ( tableName, validStates, idName ) = self.__getTypeTuple( 'Image' ) imageID = self._getFields( tableName, [ idName ], ['Name'], [imageName] ) if not imageID['OK']: return i... |
if maxCycles > 0 and self.am_getCyclesDone() == maxCyles - 1: | if maxCycles > 0 and self.am_getCyclesDone() == maxCycles - 1: | def execute( self ): """ Loop over InputPath and OutputPath pairs """ result = gConfig.getSections( self.csPath ) if not result['OK']: self.log.info( 'No Input/Output Pair defined in CS' ) return S_OK() |
def declareInstanceRunning( self, imageName, uniqueID, publicIP, privateIP ): | def declareInstanceRunning( self, imageName, uniqueID, publicIP, privateIP = "" ): | def declareInstanceRunning( self, imageName, uniqueID, publicIP, privateIP ): """ Declares an instance Running and sets its associated info (uniqueID, publicIP, privateIP) Returns S_ERROR if: - instanceName does not have a "Submitted" entry - uniqueID is not unique """ instanceID = self.__getInstanceID( uniqueID ) if i... |
self.log.info( "Finished transferring %s [%s bytes]" % ( inFile, inBytes ) ) self.__okTransferredFiles += 1 self.__okTransferredBytes += inBytes | def __retrieveAndUploadFile( self, file, outputDict ): """ Retrieve, Upload, and remove """ fileName = file inputPath = outputDict['InputPath'] inputFCName = outputDict['InputFC'] inBytes = 0 if inputFCName == 'LocalDisk': inFile = file file = os.path.join( inputPath, file ) else: inputFC = FileCatalog( [inputFCName] ) | |
ret = self.__addFilesToThreadPool( files, outputDict ) | ret = self.__addFilesToThreadPool( filesToTransfer, outputDict ) | def checkForTransfers( self ): """ Check for transfers to do and start them """ result = self.getDefinedTransferPaths() if not result[ 'OK' ]: return result tPaths = result[ 'Value' ] for name in tPaths: transferPath = tPaths[ name ] filesToTransfer = self.getOutgoingFiles( tPaths[ name ] ) ret = self.__addFilesToThrea... |
gLogger.info( "Min Working Load : %d" % self.vmMinWorkingLoad ) | gLogger.info( "Min Working Load : %f" % self.vmMinWorkingLoad ) | def __getCSConfig( self ): self.vmName = gConfig.getValue( "/LocalSite/VirtualMachineName", "" ) if not self.vmName: return S_ERROR( "/LocalSite/VirtualMachineName is not defined" ) #Variables coming from the vm imgPath = "/Resources/VirtualMachines/Images/%s" % self.vmName for csOption, csDefault, varName in ( ( "Flav... |
ret = S_OK() for file in files: file = os.path.basename( file ) self.callBackLock.acquire() if file in self.processingFiles: continue self.processingFiles[file] = 1 self.callBackLock.release() ret = self.pool.generateJobAndQueueIt( self.__retrieveAndUploadFile, args = ( file, outputDict ), oCallback = self.callBack, bl... | ret = self.__addFilesToThreadPool( files, outputDict ) | def execute( self ): """ Loop over InputPath and OutputPath pairs """ result = gConfig.getSections( self.csPath ) if not result['OK']: self.log.info( 'No Input/Output Pair defined in CS' ) return S_OK() |
if maxCycles > 0 and self.am_getCyclesDone() == maxCycles - 1: | if maxCycles > 0 and maxCycles - self.am_getCyclesDone() == 1: | def execute( self ): """ Loop over InputPath and OutputPath pairs """ result = gConfig.getSections( self.csPath ) if not result['OK']: self.log.info( 'No Input/Output Pair defined in CS' ) return S_OK() |
finalData[-1].append( max( 0, values[i] - firstValues[i] ) ) | if i in requireExtension: finalData[-1].append( max( 0, values[i] - firstValues[i] ) ) else: finalData[-1].append( values[i] ) | def getHistoryValues( self, averageBucket, selDict = {}, fields2Get = False, timespan = 0 ): try: timespan = max( 0, int( timespan ) ) except: return S_ERROR( "Timespan has to be an integer" ) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.