##// END OF EJS Templates
permissions: fixed missing user info on global and repository permissions pages.
permissions: fixed missing user info on global and repository permissions pages.

File last commit:

r4306:09801de9 default
r4418:d143e1d9 default
Show More
extensions.py
66 lines | 2.3 KiB | text/x-python | PythonLexer
file-store: rename module from upload_store to file_store.
r3453 # -*- coding: utf-8 -*-
code: update copyrights to 2020
r4306 # Copyright (C) 2016-2020 RhodeCode GmbH
file-store: rename module from upload_store to file_store.
r3453 #
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License, version 3
# (only), as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This program is dual-licensed. If you wish to learn more about the
# RhodeCode Enterprise Edition, including its added features, Support services,
# and proprietary license terms, please see https://rhodecode.com/licenses/
ANY = []
TEXT_EXT = ['txt', 'md', 'rst', 'log']
DOCUMENTS_EXT = ['pdf', 'rtf', 'odf', 'ods', 'gnumeric', 'abw', 'doc', 'docx', 'xls', 'xlsx']
IMAGES_EXT = ['jpg', 'jpe', 'jpeg', 'png', 'gif', 'svg', 'bmp', 'tiff']
AUDIO_EXT = ['wav', 'mp3', 'aac', 'ogg', 'oga', 'flac']
VIDEO_EXT = ['mpeg', '3gp', 'avi', 'divx', 'dvr', 'flv', 'mp4', 'wmv']
DATA_EXT = ['csv', 'ini', 'json', 'plist', 'xml', 'yaml', 'yml']
SCRIPTS_EXT = ['js', 'php', 'pl', 'py', 'rb', 'sh', 'go', 'c', 'h']
ARCHIVES_EXT = ['gz', 'bz2', 'zip', 'tar', 'tgz', 'txz', '7z']
EXECUTABLES_EXT = ['so', 'exe', 'dll']
DEFAULT = DOCUMENTS_EXT + TEXT_EXT + IMAGES_EXT + DATA_EXT
GROUPS = dict((
('any', ANY),
('text', TEXT_EXT),
('documents', DOCUMENTS_EXT),
('images', IMAGES_EXT),
('audio', AUDIO_EXT),
('video', VIDEO_EXT),
('data', DATA_EXT),
('scripts', SCRIPTS_EXT),
('archives', ARCHIVES_EXT),
('executables', EXECUTABLES_EXT),
('default', DEFAULT),
))
def resolve_extensions(extensions, groups=None):
"""
Calculate allowed extensions based on a list of extensions provided, and optional
groups of extensions from the available lists.
:param extensions: a list of extensions e.g ['py', 'txt']
:param groups: additionally groups to extend the extensions.
"""
groups = groups or []
valid_exts = set([x.lower() for x in extensions])
for group in groups:
if group in GROUPS:
valid_exts.update(GROUPS[group])
return valid_exts