prompt
large_stringlengths
72
9.34k
completion
large_stringlengths
0
7.61k
<|file_name|>whoispy.py<|end_file_name|><|fim▁begin|>import re import sys import whoisSrvDict import whoispy_sock import parser_branch OK = '\033[92m' FAIL = '\033[91m' ENDC = '\033[0m' def query(domainName): rawMsg = "" tldName = "" whoisSrvAddr = "" regex = re.compile('.+\..+') match = regex.se...
sys.stdout.write( FAIL ) sys.stdout.write("%s\n" % msg) sys.stdout.write( ENDC )
<|file_name|>whoispy.py<|end_file_name|><|fim▁begin|>import re import sys import whoisSrvDict import whoispy_sock import parser_branch OK = '\033[92m' FAIL = '\033[91m' ENDC = '\033[0m' def query(domainName): rawMsg = "" tldName = "" whoisSrvAddr = "" regex = re.compile('.+\..+') match = regex.se...
sys.stdout.write( OK ) sys.stdout.write("%s\n" % msg) sys.stdout.write( ENDC )
<|file_name|>whoispy.py<|end_file_name|><|fim▁begin|>import re import sys import whoisSrvDict import whoispy_sock import parser_branch OK = '\033[92m' FAIL = '\033[91m' ENDC = '\033[0m' def query(domainName): rawMsg = "" tldName = "" whoisSrvAddr = "" regex = re.compile('.+\..+') match = regex.se...
_display_fail("Invalid domain format") return None
<|file_name|>whoispy.py<|end_file_name|><|fim▁begin|>import re import sys import whoisSrvDict import whoispy_sock import parser_branch OK = '\033[92m' FAIL = '\033[91m' ENDC = '\033[0m' def query(domainName): rawMsg = "" tldName = "" whoisSrvAddr = "" regex = re.compile('.+\..+') match = regex.se...
tldName = match.group()
<|file_name|>whoispy.py<|end_file_name|><|fim▁begin|>import re import sys import whoisSrvDict import whoispy_sock import parser_branch OK = '\033[92m' FAIL = '\033[91m' ENDC = '\033[0m' def query(domainName): rawMsg = "" tldName = "" whoisSrvAddr = "" regex = re.compile('.+\..+') match = regex.se...
_display_fail("Can not parse TLD") return None
<|file_name|>whoispy.py<|end_file_name|><|fim▁begin|>import re import sys import whoisSrvDict import whoispy_sock import parser_branch OK = '\033[92m' FAIL = '\033[91m' ENDC = '\033[0m' def query(domainName): rawMsg = "" tldName = "" whoisSrvAddr = "" regex = re.compile('.+\..+') match = regex.se...
_display_fail("Not Found TLD whois server") return None
<|file_name|>whoispy.py<|end_file_name|><|fim▁begin|>import re import sys import whoisSrvDict import whoispy_sock import parser_branch OK = '\033[92m' FAIL = '\033[91m' ENDC = '\033[0m' def <|fim_middle|>(domainName): rawMsg = "" tldName = "" whoisSrvAddr = "" regex = re.compile('.+\..+') match =...
query
<|file_name|>whoispy.py<|end_file_name|><|fim▁begin|>import re import sys import whoisSrvDict import whoispy_sock import parser_branch OK = '\033[92m' FAIL = '\033[91m' ENDC = '\033[0m' def query(domainName): rawMsg = "" tldName = "" whoisSrvAddr = "" regex = re.compile('.+\..+') match = regex.se...
_display_fail
<|file_name|>whoispy.py<|end_file_name|><|fim▁begin|>import re import sys import whoisSrvDict import whoispy_sock import parser_branch OK = '\033[92m' FAIL = '\033[91m' ENDC = '\033[0m' def query(domainName): rawMsg = "" tldName = "" whoisSrvAddr = "" regex = re.compile('.+\..+') match = regex.se...
_display_safe
<|file_name|>validate_match.py<|end_file_name|><|fim▁begin|>''' Created on Mar 4, 2017 @author: preiniger ''' def __validate_alliance(alliance_color, teams, official_sr): team1sr = None team2sr = None team3sr = None # TODO: there has to be a better way... but I'd rather not touch the DB for sr i...
red_warning, red_error = __validate_alliance("Red", red_teams, red_sr) blue_warning, blue_error = __validate_alliance("Blue", blue_teams, blue_sr)
<|file_name|>validate_match.py<|end_file_name|><|fim▁begin|>''' Created on Mar 4, 2017 @author: preiniger ''' def __validate_alliance(alliance_color, teams, official_sr): <|fim_middle|> def validate_match(match, official_match, official_srs): error_level = 0 warning_messages = [] error_message...
team1sr = None team2sr = None team3sr = None # TODO: there has to be a better way... but I'd rather not touch the DB for sr in teams[0].scoreresult_set.all(): if sr.match.matchNumber == official_sr.official_match.matchNumber: team1sr = sr break for sr in teams[1...
<|file_name|>validate_match.py<|end_file_name|><|fim▁begin|>''' Created on Mar 4, 2017 @author: preiniger ''' def __validate_alliance(alliance_color, teams, official_sr): team1sr = None team2sr = None team3sr = None # TODO: there has to be a better way... but I'd rather not touch the DB for sr i...
error_level = 0 warning_messages = [] error_messages = [] red_teams = [match.red1, match.red2, match.red3] blue_teams = [match.blue1, match.blue2, match.blue3] red_sr = official_srs[0] blue_sr = official_srs[1] red_warning, red_error = __validate_alliance("Red", red_teams, red...
<|file_name|>validate_match.py<|end_file_name|><|fim▁begin|>''' Created on Mar 4, 2017 @author: preiniger ''' def __validate_alliance(alliance_color, teams, official_sr): team1sr = None team2sr = None team3sr = None # TODO: there has to be a better way... but I'd rather not touch the DB for sr i...
team1sr = sr break
<|file_name|>validate_match.py<|end_file_name|><|fim▁begin|>''' Created on Mar 4, 2017 @author: preiniger ''' def __validate_alliance(alliance_color, teams, official_sr): team1sr = None team2sr = None team3sr = None # TODO: there has to be a better way... but I'd rather not touch the DB for sr i...
team2sr = sr break
<|file_name|>validate_match.py<|end_file_name|><|fim▁begin|>''' Created on Mar 4, 2017 @author: preiniger ''' def __validate_alliance(alliance_color, teams, official_sr): team1sr = None team2sr = None team3sr = None # TODO: there has to be a better way... but I'd rather not touch the DB for sr i...
team3sr = sr break
<|file_name|>validate_match.py<|end_file_name|><|fim▁begin|>''' Created on Mar 4, 2017 @author: preiniger ''' def __validate_alliance(alliance_color, teams, official_sr): team1sr = None team2sr = None team3sr = None # TODO: there has to be a better way... but I'd rather not touch the DB for sr i...
error_messages.append((alliance_color + " team mismatch", teams, team.teamNumber))
<|file_name|>validate_match.py<|end_file_name|><|fim▁begin|>''' Created on Mar 4, 2017 @author: preiniger ''' def __validate_alliance(alliance_color, teams, official_sr): team1sr = None team2sr = None team3sr = None # TODO: there has to be a better way... but I'd rather not touch the DB for sr i...
error_messages.append((alliance_color + " wrong number of teams", 3, len(team_srs)))
<|file_name|>validate_match.py<|end_file_name|><|fim▁begin|>''' Created on Mar 4, 2017 @author: preiniger ''' def __validate_alliance(alliance_color, teams, official_sr): team1sr = None team2sr = None team3sr = None # TODO: there has to be a better way... but I'd rather not touch the DB for sr i...
warning_messages.append((alliance_color + " total score", official_sr.total_score, total_score))
<|file_name|>validate_match.py<|end_file_name|><|fim▁begin|>''' Created on Mar 4, 2017 @author: preiniger ''' def __validate_alliance(alliance_color, teams, official_sr): team1sr = None team2sr = None team3sr = None # TODO: there has to be a better way... but I'd rather not touch the DB for sr i...
error_level = 2
<|file_name|>validate_match.py<|end_file_name|><|fim▁begin|>''' Created on Mar 4, 2017 @author: preiniger ''' def __validate_alliance(alliance_color, teams, official_sr): team1sr = None team2sr = None team3sr = None # TODO: there has to be a better way... but I'd rather not touch the DB for sr i...
error_level = 1
<|file_name|>validate_match.py<|end_file_name|><|fim▁begin|>''' Created on Mar 4, 2017 @author: preiniger ''' def <|fim_middle|>(alliance_color, teams, official_sr): team1sr = None team2sr = None team3sr = None # TODO: there has to be a better way... but I'd rather not touch the DB for sr in tea...
__validate_alliance
<|file_name|>validate_match.py<|end_file_name|><|fim▁begin|>''' Created on Mar 4, 2017 @author: preiniger ''' def __validate_alliance(alliance_color, teams, official_sr): team1sr = None team2sr = None team3sr = None # TODO: there has to be a better way... but I'd rather not touch the DB for sr i...
validate_match
<|file_name|>entities_to_cascades.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ai ts=4 sts=4 et sw=4 nu from __future__ import (unicode_literals, absolute_import, division, print_function) import logging from django.core.management.base import BaseComman...
}) continue
<|file_name|>entities_to_cascades.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ai ts=4 sts=4 et sw=4 nu from __future__ import (unicode_literals, absolute_import, division, print_function) import logging from django.core.management.base import BaseComman...
option_list = BaseCommand.option_list + ( make_option('-f', help='CSV file', action='store', dest='filename'), ) def handle(self, *args, **options): headers = ['name', 'region', 'cercle_commune', 'commune_quartier'] f = op...
<|file_name|>entities_to_cascades.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ai ts=4 sts=4 et sw=4 nu from __future__ import (unicode_literals, absolute_import, division, print_function) import logging from django.core.management.base import BaseComman...
headers = ['name', 'region', 'cercle_commune', 'commune_quartier'] f = open(options.get('filename'), 'w') csv_writer = csv.DictWriter(f, fieldnames=headers) csv_writer.writeheader() csv_writer.writerow({ 'name': "label", 'region': "Région", '...
<|file_name|>entities_to_cascades.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ai ts=4 sts=4 et sw=4 nu from __future__ import (unicode_literals, absolute_import, division, print_function) import logging from django.core.management.base import BaseComman...
import unicodecsv as csv
<|file_name|>entities_to_cascades.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ai ts=4 sts=4 et sw=4 nu from __future__ import (unicode_literals, absolute_import, division, print_function) import logging from django.core.management.base import BaseComman...
import csv
<|file_name|>entities_to_cascades.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ai ts=4 sts=4 et sw=4 nu from __future__ import (unicode_literals, absolute_import, division, print_function) import logging from django.core.management.base import BaseComman...
sv_writer.writerow({ 'name': "choice_label", 'region': region.name, 'cercle_commune': cercle.name, 'commune_quartier': commune.name }) c...
<|file_name|>entities_to_cascades.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ai ts=4 sts=4 et sw=4 nu from __future__ import (unicode_literals, absolute_import, division, print_function) import logging from django.core.management.base import BaseComman...
ontinue
<|file_name|>entities_to_cascades.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ai ts=4 sts=4 et sw=4 nu from __future__ import (unicode_literals, absolute_import, division, print_function) import logging from django.core.management.base import BaseComman...
handle
<|file_name|>manage.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python import os import sys if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "MyGarden.settings") try: from django.core.management import execute_from_command_line except ImportError: # The above im...
try: import django except ImportError: raise ImportError(
<|file_name|>manage.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python import os import sys if __name__ == "__main__": <|fim_middle|> <|fim▁end|>
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "MyGarden.settings") try: from django.core.management import execute_from_command_line except ImportError: # The above import may fail for some other reason. Ensure that the # issue is really that Django is missing to avoid masking othe...
<|file_name|>console.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright (c) 2014-2016 Alberto Gacías <alberto@migasfree.org> # Copyright (c) 2015-2016 Jose Antonio Chavarría <jachavar@gmail.com> # # This program is free software: you can redistribute it and/or modify # it under t...
_ = gettext.gettext
<|file_name|>console.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright (c) 2014-2016 Alberto Gacías <alberto@migasfree.org> # Copyright (c) 2015-2016 Jose Antonio Chavarría <jachavar@gmail.com> # # This program is free software: you can redistribute it and/or modify # it under t...
f __init__(self): super(Console, self).__init__() sw = Gtk.ScrolledWindow() sw.set_policy( Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC ) self.textview = Gtk.TextView() self.textbuffer = self.textview.get_buffer() self.textview.s...
<|file_name|>console.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright (c) 2014-2016 Alberto Gacías <alberto@migasfree.org> # Copyright (c) 2015-2016 Jose Antonio Chavarría <jachavar@gmail.com> # # This program is free software: you can redistribute it and/or modify # it under t...
per(Console, self).__init__() sw = Gtk.ScrolledWindow() sw.set_policy( Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC ) self.textview = Gtk.TextView() self.textbuffer = self.textview.get_buffer() self.textview.set_editable(False) ...
<|file_name|>console.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright (c) 2014-2016 Alberto Gacías <alberto@migasfree.org> # Copyright (c) 2015-2016 Jose Antonio Chavarría <jachavar@gmail.com> # # This program is free software: you can redistribute it and/or modify # it under t...
lf.progress.pulse() return True
<|file_name|>console.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright (c) 2014-2016 Alberto Gacías <alberto@migasfree.org> # Copyright (c) 2015-2016 Jose Antonio Chavarría <jachavar@gmail.com> # # This program is free software: you can redistribute it and/or modify # it under t...
lf.hide() return True
<|file_name|>console.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright (c) 2014-2016 Alberto Gacías <alberto@migasfree.org> # Copyright (c) 2015-2016 Jose Antonio Chavarría <jachavar@gmail.com> # # This program is free software: you can redistribute it and/or modify # it under t...
init__(s
<|file_name|>console.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright (c) 2014-2016 Alberto Gacías <alberto@migasfree.org> # Copyright (c) 2015-2016 Jose Antonio Chavarría <jachavar@gmail.com> # # This program is free software: you can redistribute it and/or modify # it under t...
_timeout(s
<|file_name|>console.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright (c) 2014-2016 Alberto Gacías <alberto@migasfree.org> # Copyright (c) 2015-2016 Jose Antonio Chavarría <jachavar@gmail.com> # # This program is free software: you can redistribute it and/or modify # it under t...
_click_hide(s
<|file_name|>camera_set_partition.py<|end_file_name|><|fim▁begin|># coding: utf-8 # Copyright (C) 2017 Open Path View, Maison Du Libre # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either ver...
[ ('ref_set', ImageSet), ('images_sets', List[ImageSet]), ('start_indexes', List[int]),
<|file_name|>TestMriServer.py<|end_file_name|><|fim▁begin|>from __future__ import unicode_literals from __future__ import print_function from __future__ import division from __future__ import absolute_import from future import standard_library standard_library.install_aliases() import unittest<|fim▁hole|> from mri impo...
<|file_name|>TestMriServer.py<|end_file_name|><|fim▁begin|>from __future__ import unicode_literals from __future__ import print_function from __future__ import division from __future__ import absolute_import from future import standard_library standard_library.install_aliases() import unittest from mri import MriServe...
def test_new_dispatch(self): server = MriServer("http://www.httpbin.com", "testuser", "testpass") task = {"title": "TEST", "id": "000112233"} dispatch = server.new_dispatch(task) test_against = MriServerDispatch(task, "http://www.httpbin.com", "testuser", "testpass") self.ass...
<|file_name|>TestMriServer.py<|end_file_name|><|fim▁begin|>from __future__ import unicode_literals from __future__ import print_function from __future__ import division from __future__ import absolute_import from future import standard_library standard_library.install_aliases() import unittest from mri import MriServe...
server = MriServer("http://www.httpbin.com", "testuser", "testpass") task = {"title": "TEST", "id": "000112233"} dispatch = server.new_dispatch(task) test_against = MriServerDispatch(task, "http://www.httpbin.com", "testuser", "testpass") self.assertEqual(dispatch, test_against)
<|file_name|>TestMriServer.py<|end_file_name|><|fim▁begin|>from __future__ import unicode_literals from __future__ import print_function from __future__ import division from __future__ import absolute_import from future import standard_library standard_library.install_aliases() import unittest from mri import MriServe...
unittest.main()
<|file_name|>TestMriServer.py<|end_file_name|><|fim▁begin|>from __future__ import unicode_literals from __future__ import print_function from __future__ import division from __future__ import absolute_import from future import standard_library standard_library.install_aliases() import unittest from mri import MriServe...
test_new_dispatch
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|>class PermissionRequired(Exception): """ Exception to be thrown by views which check permissions internally. Takes a single C{perm} argument which defines the permission that caused the exception. """ def __init__(self, perm): self....
def __call__(self, view_func): def decorator(request, *args, **kwargs): if not request.user.has_perm(self.perm):
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|> class PermissionRequired(Exception): <|fim_middle|> def require_permissions(user, *permissions): for perm in permissions: if not user.has_perm(perm): raise PermissionRequired(perm) class checks_permissions(object): """ De...
""" Exception to be thrown by views which check permissions internally. Takes a single C{perm} argument which defines the permission that caused the exception. """ def __init__(self, perm): self.perm = perm
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|> class PermissionRequired(Exception): """ Exception to be thrown by views which check permissions internally. Takes a single C{perm} argument which defines the permission that caused the exception. """ def __init__(self, perm): <|f...
self.perm = perm
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|> class PermissionRequired(Exception): """ Exception to be thrown by views which check permissions internally. Takes a single C{perm} argument which defines the permission that caused the exception. """ def __init__(self, perm): sel...
for perm in permissions: if not user.has_perm(perm): raise PermissionRequired(perm)
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|> class PermissionRequired(Exception): """ Exception to be thrown by views which check permissions internally. Takes a single C{perm} argument which defines the permission that caused the exception. """ def __init__(self, perm): sel...
""" Decorator for views which handle C{PermissionRequired} errors and renders the given error view if necessary. The original request and arguments are passed to the error with the additional C{_perm} and C{_view} keyword arguments. """ def __init__(self, view_or_error=None): self.w...
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|> class PermissionRequired(Exception): """ Exception to be thrown by views which check permissions internally. Takes a single C{perm} argument which defines the permission that caused the exception. """ def __init__(self, perm): sel...
self.wrapped = callable(view_or_error) error_view = None if self.wrapped: self.view = view_or_error else: error_view = view_or_error if not error_view: from django.conf import settings error_view = settings.PERMISS...
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|> class PermissionRequired(Exception): """ Exception to be thrown by views which check permissions internally. Takes a single C{perm} argument which defines the permission that caused the exception. """ def __init__(self, perm): sel...
if not self.wrapped: self.view = view_or_request def dec(*args, **kwargs): try: return self.view(*args, **kwargs) except PermissionRequired as e: kwargs['_perm'] = e.perm kwargs['_view'] = self.view ...
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|> class PermissionRequired(Exception): """ Exception to be thrown by views which check permissions internally. Takes a single C{perm} argument which defines the permission that caused the exception. """ def __init__(self, perm): sel...
try: return self.view(*args, **kwargs) except PermissionRequired as e: kwargs['_perm'] = e.perm kwargs['_view'] = self.view return self.error_view(*args, **kwargs)
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|> class PermissionRequired(Exception): """ Exception to be thrown by views which check permissions internally. Takes a single C{perm} argument which defines the permission that caused the exception. """ def __init__(self, perm): sel...
""" Decorator which builds upon the C{checks_permission} decorator to offer the same functionality as the built-in C{django.contrib.auth.decorators.permission_required} decorator but which renders an error view insted of redirecting to the login page. """ def __init__(self, perm, error_view=...
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|> class PermissionRequired(Exception): """ Exception to be thrown by views which check permissions internally. Takes a single C{perm} argument which defines the permission that caused the exception. """ def __init__(self, perm): sel...
self.perm = perm self.error_view = error_view
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|> class PermissionRequired(Exception): """ Exception to be thrown by views which check permissions internally. Takes a single C{perm} argument which defines the permission that caused the exception. """ def __init__(self, perm): sel...
def decorator(request, *args, **kwargs): if not request.user.has_perm(self.perm): raise PermissionRequired(self.perm) return view_func(request, *args, **kwargs) return checks_permissions(self.error_view)(decorator)
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|> class PermissionRequired(Exception): """ Exception to be thrown by views which check permissions internally. Takes a single C{perm} argument which defines the permission that caused the exception. """ def __init__(self, perm): sel...
if not request.user.has_perm(self.perm): raise PermissionRequired(self.perm) return view_func(request, *args, **kwargs)
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|> class PermissionRequired(Exception): """ Exception to be thrown by views which check permissions internally. Takes a single C{perm} argument which defines the permission that caused the exception. """ def __init__(self, perm): sel...
raise PermissionRequired(perm)
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|> class PermissionRequired(Exception): """ Exception to be thrown by views which check permissions internally. Takes a single C{perm} argument which defines the permission that caused the exception. """ def __init__(self, perm): sel...
self.view = view_or_error
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|> class PermissionRequired(Exception): """ Exception to be thrown by views which check permissions internally. Takes a single C{perm} argument which defines the permission that caused the exception. """ def __init__(self, perm): sel...
error_view = view_or_error
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|> class PermissionRequired(Exception): """ Exception to be thrown by views which check permissions internally. Takes a single C{perm} argument which defines the permission that caused the exception. """ def __init__(self, perm): sel...
from django.conf import settings error_view = settings.PERMISSIONS_VIEW
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|> class PermissionRequired(Exception): """ Exception to be thrown by views which check permissions internally. Takes a single C{perm} argument which defines the permission that caused the exception. """ def __init__(self, perm): sel...
self.view = view_or_request
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|> class PermissionRequired(Exception): """ Exception to be thrown by views which check permissions internally. Takes a single C{perm} argument which defines the permission that caused the exception. """ def __init__(self, perm): sel...
raise PermissionRequired(self.perm)
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|> class PermissionRequired(Exception): """ Exception to be thrown by views which check permissions internally. Takes a single C{perm} argument which defines the permission that caused the exception. """ def <|fim_middle|>(self, perm): ...
__init__
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|> class PermissionRequired(Exception): """ Exception to be thrown by views which check permissions internally. Takes a single C{perm} argument which defines the permission that caused the exception. """ def __init__(self, perm): sel...
require_permissions
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|> class PermissionRequired(Exception): """ Exception to be thrown by views which check permissions internally. Takes a single C{perm} argument which defines the permission that caused the exception. """ def __init__(self, perm): sel...
__init__
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|> class PermissionRequired(Exception): """ Exception to be thrown by views which check permissions internally. Takes a single C{perm} argument which defines the permission that caused the exception. """ def __init__(self, perm): sel...
__call__
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|> class PermissionRequired(Exception): """ Exception to be thrown by views which check permissions internally. Takes a single C{perm} argument which defines the permission that caused the exception. """ def __init__(self, perm): sel...
dec
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|> class PermissionRequired(Exception): """ Exception to be thrown by views which check permissions internally. Takes a single C{perm} argument which defines the permission that caused the exception. """ def __init__(self, perm): sel...
__init__
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|> class PermissionRequired(Exception): """ Exception to be thrown by views which check permissions internally. Takes a single C{perm} argument which defines the permission that caused the exception. """ def __init__(self, perm): sel...
__call__
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|> class PermissionRequired(Exception): """ Exception to be thrown by views which check permissions internally. Takes a single C{perm} argument which defines the permission that caused the exception. """ def __init__(self, perm): sel...
decorator
<|file_name|>models.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- import os.path from django.db import models from django.utils.translation import ugettext_lazy as _ from django.conf import settings as django_settings from django.db.models import signals from know.plugins.attachments import settings from know...
<|file_name|>models.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- import os.path from django.db import models from django.utils.translation import ugettext_lazy as _ from django.conf import settings as django_settings from django.db.models import signals from know.plugins.attachments import settings from know...
"""File extension on upload is not allowed""" pass
<|file_name|>models.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- import os.path from django.db import models from django.utils.translation import ugettext_lazy as _ from django.conf import settings as django_settings from django.db.models import signals from know.plugins.attachments import settings from know...
objects = managers.ArticleFkManager() current_revision = models.OneToOneField( 'AttachmentRevision', verbose_name=_(u'current revision'), blank=True, null=True, related_name='current_set', help_text=_(u'The revision of this attachment currently in use (on all art...
<|file_name|>models.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- import os.path from django.db import models from django.utils.translation import ugettext_lazy as _ from django.conf import settings as django_settings from django.db.models import signals from know.plugins.attachments import settings from know...
user = kwargs.get('user', None) if not settings.ANONYMOUS and (not user or user.is_anonymous()): return False return ReusablePlugin.can_write(self, **kwargs)
<|file_name|>models.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- import os.path from django.db import models from django.utils.translation import ugettext_lazy as _ from django.conf import settings as django_settings from django.db.models import signals from know.plugins.attachments import settings from know...
return self.can_write(user=user)
<|file_name|>models.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- import os.path from django.db import models from django.utils.translation import ugettext_lazy as _ from django.conf import settings as django_settings from django.db.models import signals from know.plugins.attachments import settings from know...
verbose_name = _(u'attachment') verbose_name_plural = _(u'attachments') app_label = settings.APP_LABEL
<|file_name|>models.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- import os.path from django.db import models from django.utils.translation import ugettext_lazy as _ from django.conf import settings as django_settings from django.db.models import signals from know.plugins.attachments import settings from know...
return "%s: %s" % (self.article.current_revision.title, self.original_filename)
<|file_name|>models.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- import os.path from django.db import models from django.utils.translation import ugettext_lazy as _ from django.conf import settings as django_settings from django.db.models import signals from know.plugins.attachments import settings from know...
try: extension = filename.split(".")[-1] except IndexError: # No extension raise IllegalFileExtension("No file extension found in filename. That's not okay!") if not extension.lower() in map(lambda x: x.lower(), settings.FILE_EXTENSIONS): raise IllegalFileExtension("The follo...
<|file_name|>models.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- import os.path from django.db import models from django.utils.translation import ugettext_lazy as _ from django.conf import settings as django_settings from django.db.models import signals from know.plugins.attachments import settings from know...
from os import path extension = extension_allowed(filename) # Has to match original extension filename if instance.id and instance.attachment and instance.attachment.original_filename: original_extension = instance.attachment.original_filename.split(".")[-1] if not extension.lower() ==...
<|file_name|>models.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- import os.path from django.db import models from django.utils.translation import ugettext_lazy as _ from django.conf import settings as django_settings from django.db.models import signals from know.plugins.attachments import settings from know...
attachment = models.ForeignKey('Attachment') file = models.FileField( upload_to=upload_path, max_length=255, verbose_name=_(u'file'), storage=settings.STORAGE_BACKEND, ) description = models.TextField( blank=True, ) class Meta: verbose_name = _(...
<|file_name|>models.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- import os.path from django.db import models from django.utils.translation import ugettext_lazy as _ from django.conf import settings as django_settings from django.db.models import signals from know.plugins.attachments import settings from know...
verbose_name = _(u'attachment revision') verbose_name_plural = _(u'attachment revisions') ordering = ('created',) get_latest_by = ('revision_number',) app_label = settings.APP_LABEL
<|file_name|>models.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- import os.path from django.db import models from django.utils.translation import ugettext_lazy as _ from django.conf import settings as django_settings from django.db.models import signals from know.plugins.attachments import settings from know...
"""Used to retrieve the filename of a revision. But attachment.original_filename should always be used in the frontend such that filenames stay consistent.""" # TODO: Perhaps we can let file names change when files are replaced? if not self.file: return None f...
<|file_name|>models.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- import os.path from django.db import models from django.utils.translation import ugettext_lazy as _ from django.conf import settings as django_settings from django.db.models import signals from know.plugins.attachments import settings from know...
"""Used to retrieve the file size and not cause exceptions.""" try: return self.file.size except OSError: return None except ValueError: return None
<|file_name|>models.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- import os.path from django.db import models from django.utils.translation import ugettext_lazy as _ from django.conf import settings as django_settings from django.db.models import signals from know.plugins.attachments import settings from know...
if (not self.id and not self.previous_revision and self.attachment and self.attachment.current_revision and self.attachment.current_revision != self): self.previous_revision = self.attachment.current_revision if not self.revision_number: ...
<|file_name|>models.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- import os.path from django.db import models from django.utils.translation import ugettext_lazy as _ from django.conf import settings as django_settings from django.db.models import signals from know.plugins.attachments import settings from know...
return "%s: %s (r%d)" % (self.attachment.article.current_revision.title, self.attachment.original_filename, self.revision_number)
<|file_name|>models.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- import os.path from django.db import models from django.utils.translation import ugettext_lazy as _ from django.conf import settings as django_settings from django.db.models import signals from know.plugins.attachments import settings from know...
if not instance.file: return # Remove file path = instance.file.path.split("/")[:-1] instance.file.delete(save=False) # Clean up empty directories # Check for empty folders in the path. Delete the first two. if len(path[-1]) == 32: # Path was (most likely) obscurified so w...
<|file_name|>models.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- import os.path from django.db import models from django.utils.translation import ugettext_lazy as _ from django.conf import settings as django_settings from django.db.models import signals from know.plugins.attachments import settings from know...
return False
<|file_name|>models.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- import os.path from django.db import models from django.utils.translation import ugettext_lazy as _ from django.conf import settings as django_settings from django.db.models import signals from know.plugins.attachments import settings from know...
raise IllegalFileExtension("The following filename is illegal: %s. Extension has to be one of %s" % (filename, ", ".join(settings.FILE_EXTENSIONS)))
<|file_name|>models.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- import os.path from django.db import models from django.utils.translation import ugettext_lazy as _ from django.conf import settings as django_settings from django.db.models import signals from know.plugins.attachments import settings from know...
original_extension = instance.attachment.original_filename.split(".")[-1] if not extension.lower() == original_extension: raise IllegalFileExtension("File extension has to be '%s', not '%s'." % (original_extension, extension.lower()))
<|file_name|>models.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- import os.path from django.db import models from django.utils.translation import ugettext_lazy as _ from django.conf import settings as django_settings from django.db.models import signals from know.plugins.attachments import settings from know...
raise IllegalFileExtension("File extension has to be '%s', not '%s'." % (original_extension, extension.lower()))
<|file_name|>models.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- import os.path from django.db import models from django.utils.translation import ugettext_lazy as _ from django.conf import settings as django_settings from django.db.models import signals from know.plugins.attachments import settings from know...
instance.attachment.original_filename = filename
<|file_name|>models.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- import os.path from django.db import models from django.utils.translation import ugettext_lazy as _ from django.conf import settings as django_settings from django.db.models import signals from know.plugins.attachments import settings from know...
import random import hashlib m = hashlib.md5(str(random.randint(0, 100000000000000))) upload_path = path.join(upload_path, m.hexdigest())
<|file_name|>models.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- import os.path from django.db import models from django.utils.translation import ugettext_lazy as _ from django.conf import settings as django_settings from django.db.models import signals from know.plugins.attachments import settings from know...
filename += '.upload'
<|file_name|>models.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- import os.path from django.db import models from django.utils.translation import ugettext_lazy as _ from django.conf import settings as django_settings from django.db.models import signals from know.plugins.attachments import settings from know...
return None
<|file_name|>models.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- import os.path from django.db import models from django.utils.translation import ugettext_lazy as _ from django.conf import settings as django_settings from django.db.models import signals from know.plugins.attachments import settings from know...
self.previous_revision = self.attachment.current_revision
<|file_name|>models.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- import os.path from django.db import models from django.utils.translation import ugettext_lazy as _ from django.conf import settings as django_settings from django.db.models import signals from know.plugins.attachments import settings from know...
try: previous_revision = self.attachment.attachmentrevision_set.latest() self.revision_number = previous_revision.revision_number + 1 # NB! The above should not raise the below exception, but somehow it does. except AttachmentRevision.DoesNotExist, Att...
<|file_name|>models.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- import os.path from django.db import models from django.utils.translation import ugettext_lazy as _ from django.conf import settings as django_settings from django.db.models import signals from know.plugins.attachments import settings from know...
self.attachment.current_revision = self self.attachment.save()
<|file_name|>models.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- import os.path from django.db import models from django.utils.translation import ugettext_lazy as _ from django.conf import settings as django_settings from django.db.models import signals from know.plugins.attachments import settings from know...
return