Copy origin_* fields to a new GeographicLocation.
196231
def migrate_origin_locations(apps, _):
    

    Country = apps.get_model("glamkit_collections", "Country")
    GeographicLocation = apps.get_model("glamkit_collections", "GeographicLocation")
    WorkOrigin = apps.get_model("gk_collections_work_creator", "WorkOrigin")
    WorkBase = apps.get_model("gk_collections_work_creator", "WorkBase")

    countries = dict(((c.iso_country, c) for c in Country.objects.all()))

    for w in WorkBase.objects.all():
        if w.origin_country or \
            w.origin_state_province or \
            w.origin_city or \
            w.origin_neighborhood or \
            w.origin_colloquial:
            loc, created = GeographicLocation.objects.get_or_create(
                country=countries.get(w.origin_country, None),
                state_province=w.origin_state_province,
                city=w.origin_city,
                neighborhood=w.origin_neighborhood,
                colloquial_historical=w.origin_colloquial
            )
            WorkOrigin.objects.create(work=w, geographic_location=loc)
1091481
def ensure_geo_reference(origin):
    

    if isinstance(origin, Geo_reference):
        geo_ref = origin
    elif origin is None:
        geo_ref = None
    else:
        geo_ref = apply(Geo_reference, origin)

    return geo_ref
560106
def from_merge_origin(cls, tc):
        """"""
        other_tc = tc.tbl.tc(
            tc.row_idx + tc.rowSpan - 1,  # ---other_row_idx
            tc.col_idx + tc.gridSpan - 1  # ---other_col_idx
        )
        return cls(tc, other_tc)
822517
function copyAndOffsetMapping(existingMapping) {
    var column     = getColumnAfter(existingMapping.generatedLine - 1, existingMapping.generatedColumn);
    var newMapping = {
      generated: {
        line  : existingMapping.generatedLine,
        column: column
      }
    };
    if (existingMapping.source) {
      newMapping.source   = existingMapping.source;
      newMapping.original = {
        line  : existingMapping.originalLine,
        column: existingMapping.originalColumn
      };
      if (existingMapping.name) {
        newMapping.name = existingMapping.name;
      }
    }
    generator.addMapping(newMapping);
  }
506579
private static void writeOriginField(DataOutput out, SerializedField code, Object v)
            throws IOException {
        switch (code) {
        case ORIGIN_DESCRIPTION:
            out.writeUTF((String) v);
            break;
        case ORIGIN_LINE_NUMBER:
            out.writeInt((Integer) v);
            break;
        case ORIGIN_END_LINE_NUMBER:
            out.writeInt((Integer) v);
            break;
        case ORIGIN_TYPE:
            out.writeByte((Integer) v);
            break;
        case ORIGIN_URL:
            out.writeUTF((String) v);
            break;
        case ORIGIN_RESOURCE:
            out.writeUTF((String) v);
            break;
        case ORIGIN_COMMENTS:
            @SuppressWarnings("unchecked")
            List<String> list = (List<String>) v;
            int size = list.size();
            out.writeInt(size);
            for (String s : list) {
                out.writeUTF(s);
            }
            break;
        case ORIGIN_NULL_URL: // FALL THRU
        case ORIGIN_NULL_RESOURCE: // FALL THRU
        case ORIGIN_NULL_COMMENTS:
            // nothing to write out besides code and length
            break;
        default:
            throw new IOException("Unhandled field from origin: " + code);
        }
    }
699598
def copy(self, src_url, dst_url):
        """"""
        src_bucket, src_key = _parse_url(src_url)
        dst_bucket, dst_key = _parse_url(dst_url)

        if not dst_bucket:
            dst_bucket = src_bucket
        params = {
            'copy_source': '/'.join((src_bucket, src_key)),
            'bucket': dst_bucket,
            'key': dst_key,
        }
        return self.call("CopyObject", **params)
1363878
def ref_context_from_geoloc(geoloc):
    """"""
    text = geoloc.get('text')
    geoid = geoloc.get('geoID')
    rc = RefContext(name=text, db_refs={'GEOID': geoid})
    return rc
890899
def from_location(cls, location, north_angle=0, daylight_saving_period=None):
        """"""
        location = Location.from_location(location)
        return cls(location.latitude, location.longitude,
                   location.time_zone, north_angle, daylight_saving_period)
364477
private T copyProperties(T source) {
        T target = createEmpty(source.getClass());

        Map<String, PropertyDescriptor> mapTargetProps = MappingUtils.mapPropertyDescriptors(target.getClass());
        Map<String, PropertyDescriptor> mapSourceProps = MappingUtils.mapPropertyDescriptors(source.getClass());

        Object value = null;

        for (String propertyName : mapSourceProps.keySet()) {
            value = MappingUtils.callGetter(source, mapSourceProps.get(propertyName));

            MappingUtils.callSetter(target, mapTargetProps.get(propertyName), value);
        }

        return target;
    }
592075
def _copy_from(self, rhs):
        """"""
        self._manager = rhs._manager
        self._rlist = type(rhs._rlist)(rhs._rlist)
        self._region = rhs._region
        self._ofs = rhs._ofs
        self._size = rhs._size

        for region in self._rlist:
            region.increment_client_count()

        if self._region is not None:
            self._region.increment_client_count()
1236746
def CopyVcardFields(new_vcard, auth_vcard, field_names):
    """"""
    for field in field_names:
        value_list = auth_vcard.contents.get(field)
        new_vcard = SetVcardField(new_vcard, field, value_list)
    return new_vcard
491099
def copy_from(self, other_state):
    """"""
    for prop in self.properties().values():
      setattr(self, prop.name, getattr(other_state, prop.name))
1123061
def initialize_copy(source)
      @ptr = FFI::AutoPointer.new(
        FFIGeos.GEOSGeom_clone_r(Geos.current_handle_pointer, source.ptr),
        self.class.method(:release)
      )

      # Copy over SRID since GEOS does not
      self.srid = source.srid
    end
710690
def copycol(self, origin_col: str, dest_col: str):
        
        try:
            self.df[dest_col] = self.df[[origin_col]]
        except Exception as e:
            self.err(e, self.copy_col, "Can not copy column")
106769
def serialize_field_value_geolocalization
      return unless value
      value_object = eval(value)
      serialized = {}

      # add basic info
      serialized[:latitude] = value_object[:lat]
      serialized[:longitude] = value_object[:lng]
      serialized[:address] = value_object[:address]

      # return serialized data
      serialized
    end
29289
def address_to_coords(self, address):
        """"""

        base_coords = self.BASE_COORDS[self.region]
        get_cord = self.COORD_SERVERS[self.region]
        url_options = {
            "q": address,
            "lang": "eng",
            "origin": "livemap",
            "lat": base_coords["lat"],
            "lon": base_coords["lon"]
        }

        response = requests.get(self.WAZE_URL + get_cord, params=url_options, headers=self.HEADERS)
        for response_json in response.json():
            if response_json.get('city'):
                lat = response_json['location']['lat']
                lon = response_json['location']['lon']
                bounds = response_json['bounds']  # sometimes the coords don't match up
                if bounds is not None:
                    bounds['top'], bounds['bottom'] = max(bounds['top'], bounds['bottom']), min(bounds['top'], bounds['bottom'])
                    bounds['left'], bounds['right'] = min(bounds['left'], bounds['right']), max(bounds['left'], bounds['right'])
                else:
                    bounds = {}
                return {"lat": lat, "lon": lon, "bounds": bounds}
        raise WRCError("Cannot get coords for %s" % address)
1069293
def _copy_content(self, origin, dstPath):
        

        if hasattr(origin, 'read'):
            copy_content(origin, dstPath, self.BLOCK_SIZE, self._conf['fmode'])
        elif os.path.isfile(origin):
            with open(origin, 'rb') as f:
                copy_content(f, dstPath, self.BLOCK_SIZE, self._conf['fmode'])
        else:
            raise ValueError("Could not copy content, `origin` should be a path or a readable object")