ZP: Zone partitions.
359080
def _zp_decode(self, msg):
        """"""
        zone_partitions = [ord(x)-0x31 for x in msg[4:4+Max.ZONES.value]]
        return {'zone_partitions': zone_partitions}
161507
def update_stored_win32tz_map():
  """"""
  windows_zones_xml = download_cldr_win32tz_map_xml()
  source_hash = hashlib.md5(windows_zones_xml).hexdigest()

  if hasattr(windows_zones_xml, "decode"):
    windows_zones_xml = windows_zones_xml.decode("utf-8")

  map_zones = create_win32tz_map(windows_zones_xml)
  map_dir = os.path.dirname(os.path.abspath(__file__))
  map_filename = os.path.join(map_dir, "win32tz_map.py")
  if os.path.exists(map_filename):
    reload(win32tz_map)
    current_hash = getattr(win32tz_map, "source_hash", None)
    if current_hash == source_hash:
      return False

  map_file = open(map_filename, "w")

  comment = "Map between Windows and Olson timezones taken from %s" % (
      _CLDR_WINZONES_URL,)
  comment2 = "Generated automatically from datetime_tz.py"
  map_file.write("'''%s\n" % comment)
  map_file.write("%s'''\n" % comment2)

  map_file.write("source_hash = '%s' # md5 sum of xml source data\n" % (
      source_hash))

  map_file.write("win32timezones = {\n")
  for win32_name, territory, olson_name, comment in map_zones:
    if territory == '001':
      map_file.write("  %r: %r, # %s\n" % (
          str(win32_name), str(olson_name), comment or ""))
    else:
      map_file.write("  %r: %r, # %s\n" % (
          (str(win32_name), str(territory)), str(olson_name), comment or ""))
  map_file.write("}\n")

  map_file.close()
  return True
915360
def _smartos_zone_data():
    '''
    
    '''
    # Provides:
    #   zoneid
    #   zonename
    #   imageversion

    grains = {
        'zoneid': __salt__['cmd.run']('zoneadm list -p | awk -F: \'{ print $1 }\'', python_shell=True),
        'zonename': __salt__['cmd.run']('zonename'),
        'imageversion': 'Unknown',
    }

    imageversion = re.compile('Image:\\s(.+)')
    if os.path.isfile('/etc/product'):
        with salt.utils.files.fopen('/etc/product', 'r') as fp_:
            for line in fp_:
                line = salt.utils.stringutils.to_unicode(line)
                match = imageversion.match(line)
                if match:
                    grains['imageversion'] = match.group(1)

    return grains
451175
def parse_env_zones(self):
        ''''''
        import csv
        reader = csv.reader([os.environ.get('GCE_ZONE',"")], skipinitialspace=True)
        zones = [r for r in reader]
        return [z for z in zones[0]]
430296
def partition(a:Collection, sz:int)->List[Collection]:
    ""
    return [a[i:i+sz] for i in range(0, len(a), sz)]
1339841
def move(zone, zonepath):
    '''
    
    '''
    ret = {'status': True}

    ## verify zone
    res = __salt__['cmd.run_all']('zoneadm {zone} move {path}'.format(
        zone='-u {0}'.format(zone) if _is_uuid(zone) else '-z {0}'.format(zone),
        path=zonepath,
    ))
    ret['status'] = res['retcode'] == 0
    ret['message'] = res['stdout'] if ret['status'] else res['stderr']
    ret['message'] = ret['message'].replace('zoneadm: ', '')
    if ret['message'] == '':
        del ret['message']

    return ret
1295350
public void setHashPartitioned(FieldList partitionedFields) {
		this.partitioning = PartitioningProperty.HASH_PARTITIONED;
		this.partitioningFields = partitionedFields;
		this.ordering = null;
	}
213184
def store_zonefiles( self, zonefile_names, zonefiles, zonefile_txids, zonefile_block_heights, peer_zonefile_hashes, peer_hostport, path, con=None ):
        
        ret = []

        with AtlasDBOpen(con=con, path=path) as dbcon:

            for fetched_zfhash, zonefile_txt in zonefiles.items():
               
                if fetched_zfhash not in peer_zonefile_hashes or fetched_zfhash not in zonefile_block_heights:
                    # unsolicited
                    log.warn("%s: Unsolicited zonefile %s" % (self.hostport, fetched_zfhash))
                    continue

                rc = self.store_zonefile_data( fetched_zfhash, zonefile_txt, min(zonefile_block_heights[fetched_zfhash]), peer_hostport, dbcon, path )
                if rc:
                    # don't ask for it again
                    ret.append( fetched_zfhash )

        return ret
547434
private static synchronized Set<String> getSystemZIDs() {
        Set<String> systemZones = null;
        if (REF_SYSTEM_ZONES != null) {
            systemZones = REF_SYSTEM_ZONES.get();
        }
        if (systemZones == null) {
            Set<String> systemIDs = new TreeSet<String>();
            String[] allIDs = getZoneIDs();
            for (String id : allIDs) {
                // exclude Etc/Unknown
                if (id.equals(TimeZone.UNKNOWN_ZONE_ID)) {
                    continue;
                }
                systemIDs.add(id);
            }
            systemZones = Collections.unmodifiableSet(systemIDs);
            REF_SYSTEM_ZONES = new SoftReference<Set<String>>(systemZones);
        }
        return systemZones;
    }
396048
def partition(self):
        """"""
        step = int(math.ceil(self.num_tasks / float(self.partitions)))
        if self.indices == None:
            slice_ind = list(range(0, self.num_tasks, step))
            for start in slice_ind:
                yield self.__class__(self.partitions, 
                                     list(range(start, start + step)))
        else:
            slice_ind = list(range(0, len(self.indices), step))
            for start in slice_ind:
                if start + step <= len(self.indices):
                    yield self.__class__(self.partitions, 
                                         self.indices[start: start + step])
                else:
                    yield self.__class__(self.partitions, self.indices[start:])
903123
def startMultiple(self, zones):
        """"""
        path = 'zone/start_multiple'
        payload = {'zones': zones}
        return self.rachio.put(path, payload)
15336
def _xy_locs(mask):
  """"""
  y, x = mask.nonzero()
  return list(zip(x, y))
517930
public static String compressedListOfPartitionsInZone(final Cluster cluster, int zoneId) {
        Map<Integer, Integer> idToRunLength = PartitionBalanceUtils.getMapOfContiguousPartitions(cluster,
                                                                                                 zoneId);

        StringBuilder sb = new StringBuilder();
        sb.append("[");
        boolean first = true;
        Set<Integer> sortedInitPartitionIds = new TreeSet<Integer>(idToRunLength.keySet());
        for(int initPartitionId: sortedInitPartitionIds) {
            if(!first) {
                sb.append(", ");
            } else {
                first = false;
            }

            int runLength = idToRunLength.get(initPartitionId);
            if(runLength == 1) {
                sb.append(initPartitionId);
            } else {
                int endPartitionId = (initPartitionId + runLength - 1)
                                     % cluster.getNumberOfPartitions();
                sb.append(initPartitionId).append("-").append(endPartitionId);
            }
        }
        sb.append("]");

        return sb.toString();
    }
563802
public function removeZones()
    {
        foreach( $this->attributes['zones'] as $index => $zone )
        {
            if ( $zone->toBeAdded() )
                $this->removeZone( $index );
            else
                $zone->setAttribute( 'action', 'remove' );
        }
    }
1164091
def zone(self) -> Optional[str]:
        """"""
        if self._device_category == DC_BASEUNIT:
            return None
        return '{:02x}-{:02x}'.format(self._group_number, self._unit_number)
691652
def initialize_zones(self):
        """"""
        zone_list = self.location_info.get('zone_list', {'main': True})

        for zone_id in zone_list:
            if zone_list[zone_id]:  # Location setup is valid
                self.zones[zone_id] = Zone(self, zone_id=zone_id)
            else:                   # Location setup is not valid
                _LOGGER.debug("Ignoring zone: %s", zone_id)
1076102
@Pure
	public final OctTreeZone zoneOf(N child) {
		final int idx = indexOf(child);
		final OctTreeZone[] zones = OctTreeZone.values();
		if (idx < 0 || idx >= zones.length) {
			return zones[idx];
		}
		return null;
	}