Name of file in the form {lat}_{lon}_{ca}_{datetime}_{filename}_{hash}
488375
def exif_name(self):
        '''
        
        '''
        mapillary_description = json.loads(self.extract_image_description())

        lat = None
        lon = None
        ca = None
        date_time = None

        if "MAPLatitude" in mapillary_description:
            lat = mapillary_description["MAPLatitude"]
        if "MAPLongitude" in mapillary_description:
            lon = mapillary_description["MAPLongitude"]
        if "MAPCompassHeading" in mapillary_description:
            if 'TrueHeading' in mapillary_description["MAPCompassHeading"]:
                ca = mapillary_description["MAPCompassHeading"]['TrueHeading']
        if "MAPCaptureTime" in mapillary_description:
            date_time = datetime.datetime.strptime(
                mapillary_description["MAPCaptureTime"], "%Y_%m_%d_%H_%M_%S_%f").strftime("%Y-%m-%d-%H-%M-%S-%f")[:-3]

        filename = '{}_{}_{}_{}_{}'.format(
            lat, lon, ca, date_time, uuid.uuid4())
        return filename
19498
def get_filename(self, index):
        """"""
        if index:
            path = self.fsmodel.filePath(self.proxymodel.mapToSource(index))
            return osp.normpath(to_text_string(path))
1234473
def split_file_info(fileinfo):
    
    current_year = datetime.datetime.now().strftime('%Y')
    files = []
    for line in fileinfo:
        parts = re.split(
            r'^([\-dbclps])' +                  # Directory flag [1]
            r'([\-rwxs]{9})\s+' +               # Permissions [2]
            r'(\d+)\s+' +                       # Number of items [3]
            r'([a-zA-Z0-9_-]+)\s+' +            # File owner [4]
            r'([a-zA-Z0-9_-]+)\s+' +            # File group [5]
            r'(\d+)\s+' +                       # File size in bytes [6]
            r'(\w{3}\s+\d{1,2})\s+' +           # 3-char month and 1/2-char day of the month [7]
            r'(\d{1,2}:\d{1,2}|\d{4})\s+' +     # Time or year (need to check conditions) [+= 7]
            r'(.+)$',                           # File/directory name [8]
            line
        )

        date = parts[7]
        time = parts[8] if ':' in parts[8] else '00:00'
        year = parts[8] if ':' not in parts[8] else current_year
        dt_obj = parser.parse("%s %s %s" % (date, year, time))

        files.append({
            'directory': parts[1],
            'perms': parts[2],
            'items': parts[3],
            'owner': parts[4],
            'group': parts[5],
            'size': int(parts[6]),
            'date': date,
            'time': time,
            'year': year,
            'name': parts[9],
            'datetime': dt_obj
        })
    return files
489762
def woa_track_from_file(d, lat, lon, filename, varnames=None):
    
    d = np.asanyarray(d)
    lat = np.asanyarray(lat)
    lon = np.asanyarray(lon)

    lon[lon < 0] += 360

    doy = np.array([int(dd.strftime('%j')) for dd in d])

    nc = netCDF4.Dataset(expanduser(filename), 'r')

    if varnames is None:
        varnames = {}
        for v in nc.variables.keys():
            if nc.variables[v].dimensions == \
                    (u'time', u'depth', u'lat', u'lon'):
                        varnames[v] = v

    output = {}
    for v in varnames:
        output[v] = []

    for d_n, lat_n, lon_n in zip(doy, lat, lon):
        # Get the nearest point. In the future interpolate.
        n_d = (np.abs(d_n - nc.variables['time'][:])).argmin()
        n_x = (np.abs(lon_n - nc.variables['lon'][:])).argmin()
        n_y = (np.abs(lat_n - nc.variables['lat'][:])).argmin()

        for v in varnames:
            output[v].append(nc.variables[varnames[v]][n_d, 0, n_y, n_x])

    for v in varnames:
        output[v] = ma.fix_invalid(output[v])

    return output
918985
def ls(name, path):
    
    with Session() as session:
        try:
            print_wait('Retrieving list of files in "{}"...'.format(path))
            result = session.VFolder(name).list_files(path)
            if 'error_msg' in result and result['error_msg']:
                print_fail(result['error_msg'])
                return
            files = json.loads(result['files'])
            table = []
            headers = ['file name', 'size', 'modified', 'mode']
            for file in files:
                mdt = datetime.fromtimestamp(file['mtime'])
                mtime = mdt.strftime('%b %d %Y %H:%M:%S')
                row = [file['filename'], file['size'], mtime, file['mode']]
                table.append(row)
            print_done('Retrived.')
            print(tabulate(table, headers=headers))
        except Exception as e:
            print_error(e)
228375
def backup_name(self, timestamp=None):
        
        suffix = datetime2string(coalesce(timestamp, datetime.now()), "%Y%m%d_%H%M%S")
        return File.add_suffix(self._filename, suffix)
273294
def _file_loc(self):
        
        if self.__fname is None:
            f = os.path.splitext(os.path.basename(argv[0]))[0] + '.ini'
            cwd = os.getcwd()
            # todo: prefer script path or current path ??
            # print(os.path.realpath(sys.argv[0]))
            # todo: if os.path.exists(os.path.join(cwd, main.__file__)):
            return os.path.join(cwd, f)
        return self.__fname
224420
def dump(self, indentation=0):
        """"""
        
        dump = []
        
        dump.append('[%s]' % self.name)
        
        # Refer to the __set_format__ method for an explanation
        # of the following construct.
        for keys in self.__keys__:
            for key in keys:
                
                val = getattr(self, key)
                if isinstance(val, int) or isinstance(val, long):
                    val_str = '0x%-8X' % (val)
                    if key == 'TimeDateStamp' or key == 'dwTimeStamp':
                        try:
                            val_str += ' [%s UTC]' % time.asctime(time.gmtime(val))
                        except exceptions.ValueError, e:
                            val_str += ' [INVALID TIME]'
                else:
                    val_str = ''.join(filter(lambda c:c != '\0', str(val)))
                
                dump.append('0x%-8X 0x%-3X %-30s %s' % (
                    self.__field_offsets__[key] + self.__file_offset__, 
                    self.__field_offsets__[key], key+':', val_str))
        
        return dump
544809
def file_loc():
    """"""
    import sys
    import inspect
    try:
        raise Exception
    except:
        file_ = '.../' + '/'.join((inspect.currentframe().f_code.co_filename.split('/'))[-3:])
        line_ = sys.exc_info()[2].tb_frame.f_back.f_lineno
        return "{}:{}".format(file_, line_)
1308600
def file_hash(self, load, fnd):
        '''
        
        '''
        if 'env' in load:
            # "env" is not supported; Use "saltenv".
            load.pop('env')

        if not all(x in load for x in ('path', 'saltenv')):
            return '', None
        ret = {'hash_type': self.opts['hash_type']}
        relpath = fnd['rel']
        path = fnd['path']
        hashdest = salt.utils.path.join(self.hash_cachedir,
                                        load['saltenv'],
                                        '{0}.hash.{1}'.format(relpath,
                                                              self.opts['hash_type']))
        try:
            with salt.utils.files.fopen(hashdest, 'rb') as fp_:
                ret['hsum'] = fp_.read()
            return ret
        except IOError as exc:
            if exc.errno != errno.ENOENT:
                raise exc

        try:
            os.makedirs(os.path.dirname(hashdest))
        except OSError as exc:
            if exc.errno != errno.EEXIST:
                raise exc

        ret['hsum'] = salt.utils.hashutils.get_hash(path, self.opts['hash_type'])
        with salt.utils.files.fopen(hashdest, 'w+') as fp_:
            fp_.write(ret['hsum'])
        return ret
349731
def mtime(filename, local = false)
      str = mdtm(filename)
      ary = str.scan(MDTM_REGEXP)[0].collect {|i| i.to_i}
      return local ? Time.local(*ary) : Time.gm(*ary)
    end
836036
def upload_path(instance, filename):
    '''
        
    '''

    filename = filename.replace(" ", "_")
    filename = unicodedata.normalize('NFKD', filename).lower()
    return os.path.join(str(timezone.now().date().isoformat()), filename)
175897
def info(self):
        
        output = '{type}\nFile path: {path}\n'.format(
            type=type(self), path=pprint_thing(self._path))
        if self.is_open:
            lkeys = sorted(list(self.keys()))
            if len(lkeys):
                keys = []
                values = []

                for k in lkeys:
                    try:
                        s = self.get_storer(k)
                        if s is not None:
                            keys.append(pprint_thing(s.pathname or k))
                            values.append(
                                pprint_thing(s or 'invalid_HDFStore node'))
                    except Exception as detail:
                        keys.append(k)
                        values.append(
                            "[invalid_HDFStore node: {detail}]".format(
                                detail=pprint_thing(detail)))

                output += adjoin(12, keys, values)
            else:
                output += 'Empty'
        else:
            output += "File is CLOSED"

        return output
1025549
function encodeFileToJson(file) {
    var filePath = file.getPath();
    if (!filePath) {
        return undefined;
    }

    return {
        path: filePath,
        mtime: file.getMTime(),
        type: file.getType()
    };
}
22222
def save_location(self, filename: str, location: PostLocation, mtime: datetime) -> None:
        """"""
        filename += '_location.txt'
        location_string = (location.name + "\n" +
                           "https://maps.google.com/maps?q={0},{1}&ll={0},{1}\n".format(location.lat,
                                                                                        location.lng))
        with open(filename, 'wb') as text_file:
            shutil.copyfileobj(BytesIO(location_string.encode()), text_file)
        os.utime(filename, (datetime.now().timestamp(), mtime.timestamp()))
        self.context.log('geo', end=' ', flush=True)
527848
def get_filename(self, year):
        
        res = self.fldr + os.sep + self.type + year + '.' + self.user 
        return res
244289
function getFilename( file, postfix ) {
    let filenameParts;
    if ( typeof file === 'object' && file !== null && file.name ) {
        postfix = postfix || '';
        filenameParts = file.name.split( '.' );
        if ( filenameParts.length > 1 ) {
            filenameParts[ filenameParts.length - 2 ] += postfix;
        } else if ( filenameParts.length === 1 ) {
            filenameParts[ 0 ] += postfix;
        }
        return filenameParts.join( '.' );
    }
    return '';
}