Migrate to new FR committee abbreviations
976223
def update_abbreviations(apps, schema_editor):
    

    # Get model managers
    Group = apps.get_model("representatives", "Group")

    # Abbreviation mapping
    amap = {
        u'SenComCult': u'Culture',
        u'SenComEco': u'Économie',
        u'SenComDef': u'Défense',
        u'SenComEU': u'Europe',
        u'SenComSoc': u'Social',
        u'SenComFin': u'Finances',
        u'SenComLois': u'Lois',
        u'SenComDevD': u'',
        u'SenComAppL': u'',
        u'AnComCult': u'Culture',
        u'AnComEco': u'Économie',
        u'AnComEtrg': u'Étranger',
        u'AnComDef': u'Défense',
        u'AnComEU': u'Europe',
        u'AnComSoc': u'Social',
        u'AnComFin': u'Finances',
        u'AnComLois': u'Lois',
        u'AnComDevD': u'',
        u'AnComImmu': u'',
    }

    for old, new in amap.iteritems():
        for g in Group.objects.filter(abbreviation=old):
            g.abbreviation = new
            g.save()
223677
def translate_sbml_compound(entry, new_id, compartment_map):
    """"""
    new_entry = DictCompoundEntry(entry, id=new_id)

    if 'compartment' in new_entry.properties:
        old_compartment = new_entry.properties['compartment']
        new_entry.properties['compartment'] = compartment_map.get(
            old_compartment, old_compartment)

    # Get XHTML notes properties
    for key, value in iteritems(parse_xhtml_species_notes(entry)):
        if key not in new_entry.properties:
            new_entry.properties[key] = value

    return new_entry
1185118
def forwards(self, orm):
        ""
        for category in orm['document_library.DocumentCategory'].objects.all():
            for trans_old in orm['document_library.DocumentCategoryTitle'].objects.filter(category=category):
                orm['document_library.DocumentCategoryTranslation'].objects.create(
                    master=category,
                    language_code=trans_old.language,
                    title=trans_old.title,
                )

        for document in orm['document_library.Document'].objects.all():
            for trans_old in orm['document_library.DocumentTitle'].objects.filter(document=document):
                orm['document_library.DocumentTranslation'].objects.create(
                    master=document,
                    language_code=trans_old.language,
                    title=trans_old.title,
                    description=trans_old.description,
                    filer_file=trans_old.filer_file,
                    thumbnail=trans_old.thumbnail,
                    copyright_notice=trans_old.copyright_notice,
                    is_published=trans_old.is_published,
                    meta_description=trans_old.meta_description,
                )
1329396
def apply_docstr(docstr_func):
    
    def docstr_applier(func):
        #docstr = meta_util_six.get_funcdoc(docstr_func)
        #meta_util_six.set_funcdoc(func, docstr)
        if isinstance(docstr_func, six.string_types):
            olddoc = meta_util_six.get_funcdoc(func)
            if olddoc is None:
                olddoc = ''
            newdoc = olddoc + docstr_func
            meta_util_six.set_funcdoc(func, newdoc)
            return func
        else:
            preserved_func = preserve_sig(func, docstr_func)
            return preserved_func
    return docstr_applier
197301
def _convert_rename(self, fc):
        
        old = fc.old_path
        new = fc.new_path
        keep_old = self._path_to_be_kept(old)
        keep_new = self._path_to_be_kept(new)
        if keep_old and keep_new:
            fc.old_path = self._adjust_for_new_root(old)
            fc.new_path = self._adjust_for_new_root(new)
            return fc
        elif keep_old:
            # The file has been renamed to a non-interesting location.
            # Delete it!
            old = self._adjust_for_new_root(old)
            return commands.FileDeleteCommand(old)
        elif keep_new:
            # The file has been renamed into an interesting location
            # We really ought to add it but we don't currently buffer
            # the contents of all previous files and probably never want
            # to. Maybe fast-import-info needs to be extended to
            # remember all renames and a config file can be passed
            # into here ala fast-import?
            self.warning("cannot turn rename of %s into an add of %s yet" %
                (old, new))
        return None
1316352
protected function migrateAccountRolesUp()
    {
        if (!$this->sm->tablesExist(['typo3_flow_security_account_roles_join', 'typo3_flow_security_policy_role'])) {
            return;
        }
        $accountsWithRoles = array();

        $accountRolesResult = $this->connection->executeQuery('SELECT j.flow_security_account, r.identifier FROM typo3_flow_security_account_roles_join as j LEFT JOIN typo3_flow_security_policy_role AS r ON j.flow_policy_role = r.identifier');
        while ($accountIdentifierAndRole = $accountRolesResult->fetch(\PDO::FETCH_ASSOC)) {
            $accountIdentifier = $accountIdentifierAndRole['flow_security_account'];
            $accountsWithRoles[$accountIdentifier][] = $accountIdentifierAndRole['identifier'];
        }

        foreach ($accountsWithRoles as $accountIdentifier => $roles) {
            $this->addSql("UPDATE typo3_flow_security_account SET roleidentifiers = " . $this->connection->quote(implode(',', $roles)) . " WHERE persistence_object_identifier = " . $this->connection->quote($accountIdentifier));
        }
    }
1316303
def migrate_codec(config_old, config_new):
    '''
    '''
    assert mongodict.__version__ in [(0, 3, 0), (0, 3, 1)]

    connection = pymongo.Connection(host=config_old['host'],
                                    port=config_old['port'])
    database = connection[config_old['database']]
    collection = database[config_old['collection']]
    new_dict = mongodict.MongoDict(**config_new) # uses pickle codec by default
    total_pairs = collection.count()
    start_time = time.time()
    for counter, pair in enumerate(collection.find(), start=1):
        key, value = pair['_id'], pair['value']
        new_dict[key] = value
        if counter % REPORT_INTERVAL == 0:
            print_report(counter, total_pairs, start_time)
    print_report(counter, total_pairs, start_time)
    print('')
816500
function migrateEnsureHotKeys(settings: Settings): Settings {
  settings.hotKeyRegistry = {
    ...hotkeys.newDefaultRegistry(),
    ...settings.hotKeyRegistry,
  };
  return settings;
}
54498
def deprecated(new_fct_name, logger=None):
    
    if logger is None:
        logger = logging.getLogger("kodex")
    nfct_name = new_fct_name
    def aux_deprecated(func):
        """This is a decorator which can be used to mark functions
        as deprecated. It will result in a warning being emmitted
        when the function is used."""
        def newFunc(*args, **kwargs):
            msg = "DeprecationWarning: use '%s' instead of '%s'." % (new_fct_name, func.__name__)
            logger.warning(msg)
            warnings.warn(msg, category=DeprecationWarning)
            return func(*args, **kwargs)
        newFunc.__name__ = func.__name__
        newFunc.__doc__ = func.__doc__
        newFunc.__dict__.update(func.__dict__)
        return newFunc
    return aux_deprecated
793735
def update_kinds(apps, schema_editor):
    

    # Get model managers
    Group = apps.get_model("representatives", "Group")

    qs = Group.objects.filter(
        models.Q(name__iregex=ur'^commission d\'enquête') |
        models.Q(name__iregex=ur'^commission spéciale')
    )

    for g in qs:
        g.kind = 'delegation'
        g.save()
444052
def __update_common(self):
        """"""

        if "TCON" in self:
            # Get rid of "(xx)Foobr" format.
            self["TCON"].genres = self["TCON"].genres

        mimes = {"PNG": "image/png", "JPG": "image/jpeg"}
        for pic in self.getall("APIC"):
            if pic.mime in mimes:
                newpic = APIC(
                    encoding=pic.encoding, mime=mimes[pic.mime],
                    type=pic.type, desc=pic.desc, data=pic.data)
                self.add(newpic)
1346120
def MigrateArtifacts():
  """"""

  # First, delete all existing artifacts in REL_DB.
  artifacts = data_store.REL_DB.ReadAllArtifacts()
  if artifacts:
    logging.info("Deleting %d artifacts from REL_DB.", len(artifacts))
    for artifact in data_store.REL_DB.ReadAllArtifacts():
      data_store.REL_DB.DeleteArtifact(Text(artifact.name))
  else:
    logging.info("No artifacts found in REL_DB.")

  artifacts = artifact_registry.REGISTRY.GetArtifacts(
      reload_datastore_artifacts=True)

  logging.info("Found %d artifacts in AFF4.", len(artifacts))

  # Only migrate user-created artifacts.
  artifacts = list(filter(_IsCustom, artifacts))

  logging.info("Migrating %d user-created artifacts.", len(artifacts))

  for artifact in artifacts:
    _MigrateArtifact(artifact)
345708
def cli(ctx, feature_id, old_db, old_accession, new_db, new_accession, organism="", sequence=""):
    
    return ctx.gi.annotations.update_dbxref(feature_id, old_db, old_accession, new_db, new_accession, organism=organism, sequence=sequence)
961237
private function migrateDataFromLegacyFormat(){

        if(count($this->trees) > 0){

            //tree attributes to be migrated.
           $mapping = array(
              'editClassUrl' => array(
                'attr'   => 'selectClass',
                'action' => array(
                    'id'      => 'edit_class',
                    'name'    => 'edit class',
                    'group'   => 'none',
                    'context' => 'class',
                    'binding' => 'load'
                ) 
              ),
              'editInstanceUrl' => array(
                'attr'   => 'selectInstance',
                'action' => array(
                    'id'      => 'edit_instance',
                    'name'    => 'edit instance',
                    'group'   => 'none',
                    'context' => 'instance',
                    'binding' => 'load'
                ) 
              ),
              'addInstanceUrl'  => array(
                'attr'   => 'addInstance',
                'action' => array(
                    'id'      => 'add_instance',
                    'name'    => 'add instance',
                    'group'   => 'none',
                    'context' => 'instance',
                    'binding' => 'instantiate'
                ) 
              ),
              'addSubClassUrl'  => array(
                'attr'   => 'addClass',
                'action' => array(
                    'id'      => 'add_class',
                    'name'    => 'add class',
                    'group'   => 'none',
                    'context' => 'class',
                    'binding' => 'subClass'
                ) 
              ),
              'deleteUrl' => array(
                'attr'   => 'addClass',
                'action' => array(
                    'id'      => 'add_class',
                    'name'    => 'add class',
                    'group'   => 'none',
                    'context' => 'class',
                    'binding' => 'subClass'
                ) 
              ),
              'moveInstanceUrl' => array(
                'attr'   => 'moveInstance',
                'action' => array(
                    'id'      => 'move',
                    'name'    => 'move',
                    'group'   => 'none',
                    'context' => 'instance',
                    'binding' => 'moveNode'
                ) 
              )
           );

           foreach($this->trees as $index => $tree){
               $needMigration = false;
               $treeAttributes = $tree->getAttributes();
            
               //check if this attribute needs a migration
               foreach($treeAttributes as $attr){
                    if(array_key_exists($attr, $mapping)){
                        $needMigration = true;
                        break;
                    } 
               }
               if($needMigration){
                    $newData = array();

                    //migrate the tree
                    foreach($treeAttributes as $attr){
                        //if the attribute belongs to the mapping
                        if(array_key_exists($attr, $mapping)){
                            $url = $tree->get($attr);
                            $actionName = false;
    
                            //try to find an action with the same url
                            foreach($this->actions as $action){
                                if($action->getRelativeUrl() == $url){
                                    $actionName = $action->getId();
                                    break;
                                }
                            }
                            if($actionName){
                                $newData[$mapping[$attr]['attr']] = $actionName;
                            } else {
    
                                //otherwise create a new action from the mapping
                                $newData[$mapping[$attr]['attr']] = $mapping[$attr]['action']['id'];
                                $actionData = $mapping[$attr]['action'];
                                $actionData['url'] = $url;
                                
                                list($extension, $controller, $action) = explode('/', trim($url, '/'));
                                $actionData['extension'] = $extension;
                                $actionData['controller'] = $controller;
                                $actionData['action'] = $action;
                                
                                $this->actions[] = new Action($actionData); 
                            }
                        } else {
                            $newData[$attr] = $tree->get($attr);
                        }
                    }
    
                    //the tree is replaced
                    $this->trees[$index] = new Tree($newData);
               }
           }
        }
    }
392698
def groups_rename(self, room_id, name, **kwargs):
        """"""
        return self.__call_api_post('groups.rename', roomId=room_id, name=name, kwargs=kwargs)
1362215
function() {
			var node = new AbbreviationNode();
			var attrs = ['abbreviation', 'counter', '_name', '_text', 'repeatCount', 'hasImplicitRepeat', 'start', 'end', 'content', 'padding'];
			attrs.forEach(function(a) {
				node[a] = this[a];
			}, this);
			
			// clone attributes
			node._attributes = this._attributes.map(function(attr) {
				return utils.extend({}, attr);
			});
			
			node._data = utils.extend({}, this._data);
			
			// clone children
			node.children = this.children.map(function(child) {
				child = child.clone();
				child.parent = node;
				return child;
			});
			
			return node;
		}
277947
def rm_token(self, tok):
        '''
        
        '''
        self.tokens["{0}.rm_token".format(self.opts['eauth_tokens'])](self.opts, tok)