Пример #1
0
def splitPathInfo(pathinfo):
    """ Converts a PATH_INFO string to layer name, coordinate, and extension parts.

        Example: "/layer/0/0/0.png", leading "/" optional.
    """
    if pathinfo == '/':
        return None, None, None
    elif pathinfo == '/health':
        return None, None, None

    if _pathinfo_pat.match(pathinfo or ''):
        path = _pathinfo_pat.match(pathinfo)
        layer, row, column, zoom, extension = [path.group(p) for p in 'lyxze']
        coord = Coordinate(int(row), int(column), int(zoom))

    elif _preview_pat.match(pathinfo or ''):
        path = _preview_pat.match(pathinfo)
        layer, extension = path.group('l'), 'html'
        coord = None

    else:
        raise Core.KnownUnknown(
            'Bad path: "%s". I was expecting something more like "/example/0/0/0.png"'
            % pathinfo)

    return layer, coord, extension
Пример #2
0
def parse_csv(input):
    csv_path_re = re.compile(r'^\/?\S+\.csv')
    path = csv_path_re.match(input)
    if path == None:
        return parse_csv_data(data= input)
    else:
        return parse_csv_file(path= path.group())
def splitPathInfo(pathinfo):
    """ Converts a PATH_INFO string to layer name, coordinate, and extension parts.
        
        Example: "/layer/0/0/0.png", leading "/" optional.
    """
    if pathinfo == '/':
        return None, None, None
    
    if _pathinfo_pat.match(pathinfo or ''):
        path = _pathinfo_pat.match(pathinfo)
        layer, row, column, zoom, extension = [path.group(p) for p in 'lyxze']
        coord = Coordinate(int(row), int(column), int(zoom))

    elif _preview_pat.match(pathinfo or ''):
        path = _preview_pat.match(pathinfo)
        layer, extension = path.group('l'), 'html'
        coord = None

    else:
        raise Core.KnownUnknown('Bad path: "%s". I was expecting something more like "/example/0/0/0.png"' % pathinfo)

    return layer, coord, extension
Пример #4
0
 def check_root(self):
     """
     This method requests the root page and searches for a specific string.
         Usually there are some TYPO3 notes in the HTML comments.
         If found, it searches for a Typo3 path reference
         in order to determine the Typo3 installation path.
     """
     full_path = self.get_name()
     response = request.get_request('{}'.format(self.get_name()))
     if re.search('powered by TYPO3', response['html']):
         self.set_typo3()
         path = re.search(
             '="(?:{})/?(\S*?)/?(?:typo3temp|typo3conf)/'.format(
                 self.get_name()), response['html'])
         if path and path.group(1) != '':
             full_path = '{}/{}'.format(self.get_name(), path)
     self.set_path(full_path)
Пример #5
0
        
        Example: "/layer/0/0/0.png", leading "/" optional.
    """
    if pathinfo == '/':
        return None, None, None

    if pathinfo == '/favicon.ico':
        try:
            f = open('favicon.ico')
            return 200, Headers([('Content-Type', 'image/x-icon')]), f.read()
        except IOError, e:
            return 404, None, None
            
    if _pathinfo_pat.match(pathinfo or ''):
        path = _pathinfo_pat.match(pathinfo)
        layer, row, column, zoom, extension = [path.group(p) for p in 'lyxze']
        coord = Coordinate(int(row), int(column), int(zoom))

    elif _preview_pat.match(pathinfo or ''):
        path = _preview_pat.match(pathinfo)
        layer, extension = path.group('l'), 'html'
        coord = None

    else:
        raise Core.KnownUnknown('Bad path: "%s". I was expecting something more like "/example/0/0/0.png"' % pathinfo)

    return layer, coord, extension

def mergePathInfo(layer, coord, extension):
    """ Converts layer name, coordinate and extension back to a PATH_INFO string.