<commit_before>from rorn.Box import LoginBox, ErrorBox, WarningBox

from DB import ActiveRecord
from utils import *

class Privilege(ActiveRecord):
	def __init__(self, name, description, arguments, id = None):
		ActiveRecord.__init__(self)
		self.id = id
		self.name = name
		self.description = description
		self.arguments = arguments

	def argument(i):
		return self.arguments.split(',')[i]

	def __str__(self):
		return self.name

def requirePriv(handler, priv):
	if isinstance(priv, Privilege):
		priv = priv.name

	if not handler.session['user']:
		print LoginBox()
		done()

	if not handler.session['user'].hasPrivilege(priv):
		print ErrorBox('Forbidden', "You need the <b>%s</b> privilege" % priv)
		done()

def admin(handler):
	requirePriv(handler, 'Dev')
	handler.replace('$headerbg$', '#AA0000', 1)

def dev(handler):
	if handler.session['user'].hasPrivilege('Dev'):
		print WarningBox('Under development', close = True)<commit_msg>Changed Privilege.dev() to respect the build mode<commit_after>from rorn.Box import LoginBox, ErrorBox, WarningBox

from DB import ActiveRecord
from LoadValues import isDevMode
from utils import *

class Privilege(ActiveRecord):
	def __init__(self, name, description, arguments, id = None):
		ActiveRecord.__init__(self)
		self.id = id
		self.name = name
		self.description = description
		self.arguments = arguments

	def argument(i):
		return self.arguments.split(',')[i]

	def __str__(self):
		return self.name

def requirePriv(handler, priv):
	if isinstance(priv, Privilege):
		priv = priv.name

	if not handler.session['user']:
		print LoginBox()
		done()

	if not handler.session['user'].hasPrivilege(priv):
		print ErrorBox('Forbidden', "You need the <b>%s</b> privilege" % priv)
		done()

def admin(handler):
	requirePriv(handler, 'Dev')
	handler.replace('$headerbg$', '#AA0000', 1)

def dev(handler):
	if isDevMode(handler):
		print WarningBox('Under development', close = True)
{'fraction_non_alphanumeric': 0.13212435233160622, 'fraction_numerical': 0.0051813471502590676, 'mean_word_length': 5.2290322580645165, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5058343', 'n_tokens_mistral': 657, 'n_tokens_neox': 615, 'n_words': 171}