Define one resource attribute from one network as being the same as
        that from another network.
545999
def set_attribute_mapping(resource_attr_a, resource_attr_b, **kwargs):
    
    user_id = kwargs.get('user_id')
    ra_1 = get_resource_attribute(resource_attr_a)
    ra_2 = get_resource_attribute(resource_attr_b)

    mapping = ResourceAttrMap(resource_attr_id_a = resource_attr_a,
                             resource_attr_id_b  = resource_attr_b,
                             network_a_id     = ra_1.get_network().id,
                             network_b_id     = ra_2.get_network().id )

    db.DBSession.add(mapping)

    db.DBSession.flush()

    return mapping
716385
def __copy(self, other):
        """"""
        self.__data = copy.deepcopy(other.data)
        self.__classes = copy.deepcopy(other.classes)
        self.__labels = copy.deepcopy(other.labels)
        self.__dtype = copy.deepcopy(other.dtype)
        self.__description = copy.deepcopy(other.description)
        self.__feature_names = copy.deepcopy(other.feature_names)
        self.__num_features = copy.deepcopy(other.num_features)

        return self
565301
def samefile(self, other_path):
        
        if hasattr(os.path, "samestat"):
            st = self.stat()
            try:
                other_st = other_path.stat()
            except AttributeError:
                other_st = os.stat(other_path)
            return os.path.samestat(st, other_st)
        else:
            filename1 = six.text_type(self)
            filename2 = six.text_type(other_path)
            st1 = _win32_get_unique_path_id(filename1)
            st2 = _win32_get_unique_path_id(filename2)
            return st1 == st2
75008
def attributes(self):
        """"""
        attr = {
            'name': self.name,
            'id': self.sync_id,
            'network_id': self.network_id,
            'serial': self.serial,
            'status': self.status,
            'region': self.region,
            'region_id': self.region_id,
        }
        return attr
1224447
def summ(other)
			if (!other.kind_of?(IPv4Net))
				raise ArgumentError, "Expected an IPv4Net object for 'other' but got a #{other.class}."
			end
			
			# netmasks must be identical
			if (self.netmask.prefix_len != other.netmask.prefix_len)
				return nil
			end
			
			# merge-able networks will be identical if you right shift them by the number of bits in the hostmask + 1
			shift = 32 - self.netmask.prefix_len + 1
			addr = self.network.addr >> shift
			otherAddr = other.network.addr >> shift
			if (addr != otherAddr)
				return nil
			end
			return self.resize(self.netmask.prefix_len - 1)
		end
595299
def copy(self):
        
        c = copy.deepcopy(self)
        for key in c.conns:
            c.conns[key] = self.conns[key].copy()
        return c
187702
def same_domain(self, other):
        
        return self.domain == other.domain or \
                len(self.domain.symmetric_difference(set(other.domain))) == 0
816644
def sync(self, graph_commons):
        """"""
        if self['id'] is None:
            return

        remote_graph = graph_commons.graphs(self['id'])

        # TODO: less forceful, more elegant
        self.edges = remote_graph.edges
        self.nodes = remote_graph.nodes
        self.node_types = remote_graph.node_types
        self.edge_types = remote_graph.edge_types
        self._edges = dict((edge['id'], edge) for edge in self.edges)
        self._nodes = dict((node['id'], node) for node in self.nodes)
        self._node_types = dict((t['id'], t) for t in self.node_types)
        self._edge_types = dict((t['id'], t) for t in self.edge_types)
1359713
def get_resource_attributes(ref_key, ref_id, type_id=None, **kwargs):
    

    user_id = kwargs.get('user_id')

    resource_attr_qry = db.DBSession.query(ResourceAttr).filter(
        ResourceAttr.ref_key == ref_key,
        or_(
            ResourceAttr.network_id==ref_id,
            ResourceAttr.node_id==ref_id,
            ResourceAttr.link_id==ref_id,
            ResourceAttr.group_id==ref_id
        ))

    if type_id is not None:
        attr_ids = []
        rs = db.DBSession.query(TypeAttr).filter(TypeAttr.type_id==type_id).all()
        for r in rs:
            attr_ids.append(r.attr_id)

        resource_attr_qry = resource_attr_qry.filter(ResourceAttr.attr_id.in_(attr_ids))

    resource_attrs = resource_attr_qry.all()

    return resource_attrs
359837
def get_network_mappings(network_id, network_2_id=None, **kwargs):
    
    qry = db.DBSession.query(ResourceAttrMap).filter(
        or_(
            and_(
                ResourceAttrMap.resource_attr_id_a == ResourceAttr.id,
                ResourceAttr.network_id == network_id),
            and_(
                ResourceAttrMap.resource_attr_id_b == ResourceAttr.id,
                ResourceAttr.network_id == network_id)))

    if network_2_id is not None:
        aliased_ra = aliased(ResourceAttr, name="ra2")
        qry = qry.filter(or_(
            and_(
                ResourceAttrMap.resource_attr_id_a == aliased_ra.id,
                aliased_ra.network_id == network_2_id),
            and_(
                ResourceAttrMap.resource_attr_id_b == aliased_ra.id,
                aliased_ra.network_id == network_2_id)))

    return qry.all()
1106268
def sameState (s1, s2):
    
    if (len(s1[1]) != len(s2[1])) or (s1[2] != s2[2]):
        return False
    for arcIndex in range(0, len(s1[1])):
        arc1 = s1[1][arcIndex]
        arc2 = s2[1][arcIndex]
        if arc1[:-1] != arc2[:-1]:
            return False
    return True
1296439
def copy(self):
        
        _conns = self._conns
        self._conns = {}
        c = copy.deepcopy(self)
        self._conns = _conns
        return c
143310
def common_wire_version(self):
        """"""
        servers = self.known_servers
        if servers:
            return min(s.max_wire_version for s in self.known_servers)

        return None
589320
def env_same_host(env1, env2):
    
    config = _config_file()

    h1 = dict(config.items(env1))['base_url']
    h2 = dict(config.items(env2))['base_url']

    return h1 == h2
758293
def identical(self, other):
        
        try:
            return (utils.dict_equiv(self.attrs, other.attrs) and
                    self.equals(other))
        except (TypeError, AttributeError):
            return False
797281
def samefile(path1, path2, user=None):
    
    def tr(p):
        return abspath(normpath(realpath(p)), user=user)
    return tr(path1) == tr(path2)
9513
def set_neighbor_attribute_map(neigh_ip_address, at_maps,
                               route_dist=None, route_family=VRF_RF_IPV4):
    """"""
    core = CORE_MANAGER.get_core_service()
    peer = core.peer_manager.get_by_addr(neigh_ip_address)

    at_maps_key = const.ATTR_MAPS_LABEL_DEFAULT
    at_maps_dict = {}

    if route_dist is not None:
        vrf_conf =\
            CORE_MANAGER.vrfs_conf.get_vrf_conf(route_dist, route_family)
        if vrf_conf:
            at_maps_key = ':'.join([route_dist, route_family])
        else:
            raise RuntimeConfigError(desc='No VrfConf with rd %s' %
                                          route_dist)

    at_maps_dict[const.ATTR_MAPS_LABEL_KEY] = at_maps_key
    at_maps_dict[const.ATTR_MAPS_VALUE] = at_maps
    peer.attribute_maps = at_maps_dict

    return True