content stringlengths 1 1.13k | length int64 1 1.13k |
|---|---|
# Copyright (C) 2016 EMC Corporation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requ... | 1,023 |
GROUP_SNAPSHOT_API_VERSION = '3.14'
class GroupSnapshotsController(wsgi.Controller):
"""The group_snapshots API controller for the OpenStack API."""
_view_builder_class = group_snapshot_views.ViewBuilder
def __init__(self):
self.group_snapshot_api = group_api.API()
super(GroupSnapshotsCo... | 1,015 |
LOG.info(_LI('Delete group_snapshot with id: %s'), id, context=context)
try:
group_snapshot = self.group_snapshot_api.get_group_snapshot(
context,
group_snapshot_id=id)
self.group_snapshot_api.delete_group_snapshot(context,
... | 857 |
@wsgi.Controller.api_version(GROUP_SNAPSHOT_API_VERSION)
def index(self, req):
"""Returns a summary list of group_snapshots."""
return self._get_group_snapshots(req, is_detail=False)
@wsgi.Controller.api_version(GROUP_SNAPSHOT_API_VERSION)
def detail(self, req):
"""Returns a det... | 742 |
if is_detail:
group_snapshots = self._view_builder.detail_list(req, limited_list)
else:
group_snapshots = self._view_builder.summary_list(req,
limited_list)
return group_snapshots
@wsgi.Controller.api_vers... | 979 |
name = group_snapshot.get('name', None)
description = group_snapshot.get('description', None)
LOG.info(_LI("Creating group_snapshot %(name)s."),
{'name': name},
context=context)
try:
new_group_snapshot = self.group_snapshot_api.create_group... | 752 |
#######################################################################
# Copyright 2012 Mark Wolf
#
# This file is part of OrgWolf.
#
# OrgWolf 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 version 3... | 873 |
This module contains the WSGI application used by Django's development server
and any production WSGI deployments. It should expose a module-level variable
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
this application via the ``WSGI_APPLICATION`` setting.
Usually you will have the st... | 997 |
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from core import perf_benchmark
from telemetry import benchmark
from telemetry.timeline import tracing_category_filter
from telemetry.web_perf import timeli... | 931 |
@classmethod
def ValueCanBeAddedPredicate(cls, value, is_first_result):
if 'text-selection' not in value.name:
return False
return value.values != None
# See crbug.com/519044
@benchmark.Disabled('all')
class TextSelectionDirection(_TextSelection):
"""Measure text selection metrics while dragging a... | 1,022 |
@classmethod
def Name(cls):
return 'text_selection.character'
| 70 |
# coding: utf-8
import os
import re
import hashlib
import time
from string import strip
from datetime import datetime, timedelta, date
from dateutil.relativedelta import relativedelta
from flask import current_app, request, flash, render_template, session, redirect, url_for
from lac.data_modelz import *
from lac.helper... | 496 |
class Engine(object):
def __init__(self, app=None):
if app is not None:
self.app = app
self.init_app(self.app)
else:
self.app = None
def init_app(self, app):
if not hasattr(app, 'extensions'):
app.extensions = {}
app.extensions['e... | 646 |
def is_ccc_group(self, member):
return 'ccc' == self.cache.get_group_from_member_uid(member)
def is_cines_group(self, uid):
return 'cines' == self.cache.get_group_from_member_uid(uid)
def is_principal_group(self, member, group):
return self.cache.get_posix_group_cn_by_gid(member['g... | 343 |
def disable_account(self, user):
user_attr = user.get_attributes()
mod_attr = [('pwdAccountLockedTime', "000001010000Z")]
user_uid = user_attr['uid'][0]
if self.cache.get_group_from_member_uid(user_uid) == 'ccc':
new_shadow_expire_datetime = datetime.now() - timedelta(day... | 976 |
new_shadow_expire_datetime = self.converter.days_number_to_datetime(
user.get_attributes()['cinesdaterenew'][0]
) + relativedelta(
months = +self.app.config['SHADOW_DURATION']
)
new_shadow_expire = str(
self.converter.dateti... | 756 |
def get_search_user_fieldz(self):
page = Page.query.filter_by(label = "search_user").first()
page_attributez = Field.query.filter_by(page_id = page.id).all()
return page_attributez
def get_search_user_attributez(self):
search_attributez = [attr.label.encode('utf-8')
... | 412 |
def get_resultz_from_search_user_form(self, form):
filter_list =[]
if form.uid_number.data != "" :
filter_list.append("(uidNumber={0})".format(
strip(form.uid_number.data)
))
if form.sn.data != "" :
filter_list.append("(sn=*{0}*)".format(
... | 1,017 |
))
if form.user_type.data == "":
base_dn = "ou=people,{0}".format(self.ldap_search_base)
else:
base_dn = "ou={0},ou=people,{1}".format(form.user_type.data,
self.ldap_search_base)
if filter_list != [] :
ldap... | 689 |
def get_search_group_fieldz(self):
page = Page.query.filter_by(label = "search_group").first()
page_attributez = Field.query.filter_by(page_id = page.id, display=True).all()
return page_attributez
def get_search_group_attributez(self):
search_attributez = [attr.label.encode('utf... | 430 |
def get_resultz_from_search_group_form(self, form):
filter_list =[]
if form.gid_number.data != "" :
filter_list.append("(gidNumber={0})".format(
strip(form.gid_number.data)
))
if form.cn.data != "" :
filter_list.append("(cn=*{0}*)".format(
... | 991 |
ldap_filter = "(objectClass=posixGroup)"
search_resultz = self.ldap.search(
ldap_filter=ldap_filter,
attributes=self.get_search_group_attributez(),
base_dn=base_dn)
return search_resultz | 250 |
def update_group_memberz_cines_c4(self, branch, group, comite):
memberz_uid = self.ldap.get_posix_group_memberz(branch, group)
if len(memberz_uid)>1:
ldap_filter = '(&(objectClass=posixAccount)(|{0}))'.format(
''.join(['(uid={0})'.format(uid) for uid in memberz_uid]))
... | 738 |
def update_user_cines_c4(self, user, group, comite):
user_attrz = user.get_attributes()
user_uid = user_attrz['uid'][0]
if (
self.is_ccc_group(user_uid)
and (
'cinesC4' not in user_attrz
or user_attrz['cinesC4'][0] != co... | 1,002 |
[('cinesC4', comite.encode('utf-8'))])
print(u'{0} : Nouveau comité pour {1} -> {2}'.format(
session['uid'],
user_uid,
comite).encode('utf-8')
) | 238 |
def add_user_to_container(self, user_uid, container_cn):
container_dn = "cn={0},ou=grConteneur,ou=groupePosix,{1}".format(
container_cn,
self.ldap_search_base
)
pre_modlist = []
pre_modlist.append(('memberUid', [user_uid.encode('utf-8')]))
self.ldap.ad... | 729 |
def update_password_from_form(self, form, uid):
pre_modlist = []
if self.cache.get_group_from_member_uid(uid) == 'cines':
nt_hash = hashlib.new(
'md4',
strip(form.new_pass.data).encode('utf-16le')
).hexdigest().upper()
pre_modlist =... | 422 |
if uid != session['uid']:
pre_modlist.append(('userPassword',
strip(form.new_pass.data).encode('utf-8')))
if self.cache.get_group_from_member_uid(uid) not in ['autre', 'soft']:
pre_modlist.append(('pwdReset', 'TRUE'))
if self.ld... | 993 |
u'Votre mot de passe a été mis à jour avec succès.'.format(uid)
)
print(u'{0} : Mise à jour du mot de passe pour {1}'.format(
session['uid'],
uid).encode('utf-8')
)
if pre_modlist:
sel... | 410 |
def update_page_from_form(self, page, raw_form):
form = raw_form['form']
page_oc_id_list = raw_form['page_oc_id_list']
page_unic_attr_id_list = raw_form['page_unic_attr_id_list']
attr_label_list = raw_form['attr_label_list']
if attr_label_list is not None:
self.up... | 983 |
print("Suppression de l'Object Class id {0}".format(oc_id))
PageObjectClass.query.filter_by(page_id=page.id,
ldapobjectclass_id= oc_id
).delete()
attr_to_del_list = [
... | 994 |
print("Creation de l'attribut id {0}".format(attr_id))
attr = LDAPAttribute.query.filter_by(id = attr_id).first()
self.create_default_field(attr, page)
if page_unic_attr_id_list is not None:
# On traite les Attributes supprimées
... | 773 |
def update_lac_admin_from_form(self, form):
group_dn = "cn=lacadmin,ou=system,{0}".format(self.ldap_search_base)
memberz = [ get_uid_from_dn(dn)
for dn in self.ldap.get_lac_admin_memberz() ]
if form.selected_memberz.data is not None:
memberz_to_add = []
... | 1,011 |
if memberz_to_del:
self.ldap.remove_dn_attribute(group_dn,
[('member', member.encode('utf8'))
for member in memberz_to_del]
)
self.fm.populate_ldap_admin_ch... | 561 |
def update_ldap_admin_from_form(self, form):
group_dn = "cn=ldapadmin,ou=system,{0}".format(self.ldap_search_base)
memberz = [ get_uid_from_dn(dn)
for dn in self.ldap.get_ldap_admin_memberz() ]
if form.selected_memberz.data is not None:
memberz_to_add = []
... | 1,000 |
if memberz_to_del:
self.ldap.remove_dn_attribute(group_dn,
[('member', member.encode('utf8'))
for member in memberz_to_del]
)
self.fm.populate_ldap_admin_choices(fo... | 554 |
def get_last_used_id(self, ldap_ot):
attributes=['gidNumber'] if ldap_ot.apply_to == 'group' else ['uidNumber']
if ldap_ot.apply_to == 'group':
ldap_filter = '(objectClass=posixGroup)'
else:
ldap_filter = '(objectClass=posixAccount)'
base_dn='ou={0},ou={1},{2}... | 801 |
def is_active(self, user):
user_attrz = user.get_attributes()
if ('shadowExpire' in user_attrz and datetime.now()> self.converter.days_number_to_datetime(
user_attrz['shadowExpire'][0]
)) or ('pwdAccountLockedTime' in user_attrz):
return False
else:
... | 337 |
def create_default_quota(self, form):
cn = strip(form.common_name.data).encode('utf-8')
dn = 'cn={0},ou=quota,ou=system,{1}'.format(cn, self.ldap_search_base)
cinesQuotaSizeHard = self.fm.get_quota_value_from_form(
form,
'cinesQuotaSizeHard')
cinesQuotaSizeSof... | 1,013 |
print(u'{0} : Quota par défaut {1} créé'.format(
session['uid'],
cn).encode('utf-8')
) | 126 |
def update_default_quota(self, storage_cn, form):
storage_dn = "cn={0},ou=quota,ou=system,{1}".format(
storage_cn,
self.ldap_search_base
)
cinesQuotaSizeHard = self.fm.get_quota_value_from_form(
form,
'cinesQuotaSizeHard')
cinesQuotaSiz... | 1,126 |
def update_quota(self, storage, form):
storage_cn = storage['cn'][0]
default_storage_cn, group_id = storage_cn.split('.G.')
default_storage = self.ldap.get_default_storage(default_storage_cn).get_attributes()
storage_dn = "cn={0},cn={1},ou={2},ou=groupePosix,{3}".format(
... | 1,065 |
if form.cinesQuotaSizeTempExpire.data:
cinesQuotaSizeTempExpire = self.converter.datetime_to_timestamp(
form.cinesQuotaSizeTempExpire.data
).encode('utf-8')
if (form.cinesQuotaSizeTempExpire.data is not None
and (
'cinesQuot... | 1,001 |
or cinesQuotaInodeTempExpire != storage[
'cinesQuotaInodeTempExpire'
]
)
):
pre_modlist.append(('cinesQuotaInodeTempExpire',
cinesQuotaInodeTempExpire))
self.ldap.updat... | 504 |
def populate_last_used_idz(self):
ignore_ot_list = ['reserved', 'grLight', 'grPrace']
ldap_otz = LDAPObjectType.query.all()
for ldap_ot in ldap_otz:
if ldap_ot.label not in ignore_ot_list:
last_used_id = self.get_last_used_id(ldap_ot)
id_range = se... | 832 |
def create_ldap_object_from_add_group_form(self, form, page_label):
ot = LDAPObjectType.query.filter_by(label = page_label).first()
cn = strip(form.cn.data).encode('utf-8')
description = strip(form.description.data).encode('utf-8')
id_number = str(self.get_next_id_from_ldap_ot(ot))
... | 654 |
full_dn = "cn={0},ou={1},ou=groupePosix,{2}".format(
cn,
ot.label,
self.ldap_search_base)
add_record = [('cn', [cn]),
('gidNumber', [id_number]),
('objectClass', object_classes)]
if page_label != 'grProjet':
... | 920 |
if self.ldap.add(full_dn, add_record):
ot.last_used_id= id_number
db.session.add(ot)
db.session.commit()
self.cache.populate_grouplist()
self.cache.populate_people_group()
flash(u'Groupe créé')
print(u'{0} : Groupe posix {1} cré... | 1,022 |
full_dn = "cn={0},ou=grTravail,{1}".format(
cn,
self.ldap_search_base)
add_record = [('cn', [cn]),
('cinesGrWorkType', [
getattr(form, 'cinesGrWorkType').data.encode('utf-8')
]),
('uniqueM... | 864 |
def create_ldap_object_from_add_container_form(self, form):
ot = LDAPObjectType.query.filter_by(label = 'grConteneur').first()
cn = strip(form.cn.data).encode('utf-8')
description = strip(form.description.data).encode('utf-8')
object_classes = [oc_ot.ldapobjectclass.label.encode('utf... | 648 |
full_dn = "cn={0},ou=grConteneur,ou=groupePosix,{1}".format(
cn,
self.ldap_search_base)
add_record = [('cn', [cn]),
('gidNumber', [id_number]),
('objectClass', object_classes)]
if description and description != '':
a... | 755 |
def create_ldap_object_from_add_user_form(self, form, fieldz, page):
ldap_ot = LDAPObjectType.query.filter_by(
label=page.label
).first()
ldap_ot_ocz = LDAPObjectTypeObjectClass.query.filter_by(
ldapobjecttype_id = ldap_ot.id
).all()
ot_oc_list = [oc.l... | 996 |
form_field_values = []
if (field.label not in ['cinesUserToPurge', 'cn', 'cinesIpClient']
and form_field_values != [''] ):
form_attributez.append((field.label, form_field_values))
if (field.label == 'cinesIpClient' and form_field_values != ['']... | 1,006 |
add_record.append(
('homeDirectory', "/home/{0}".format(uid).encode('utf-8')))
add_record.append(
('shadowlastchange',
[str(self.converter.datetime_to_days_number(datetime.now()))]
)
)
if 'cinesusr' in ot_oc_list:
add_record.appen... | 1,010 |
if comite != '':
add_record.append(
('cinesC4', comite.encode('utf-8'))
)
self.add_user_to_container(uid, comite)
if ldap_ot.ppolicy != '':
add_record.append(
('pwdPolicySubentry',
'cn={0},ou... | 991 |
flash(u'L\'utilisateur n\'a pas été créé')
return True | 74 |
def create_ldap_object_from_add_object_type_form(self,
form,
ldap_object_type ):
selected_oc_choices = self.fm.get_ot_oc_choices(ldap_object_type)
ot_oc_id_list = [oc[0] for oc in selected_oc_ch... | 1,018 |
ldap_object_type.id, oc_id)
db.session.add(ot_oc)
# On traite les ObjectClass supprimées
# et les fieldz associés en cascade
for oc_id in ot_oc_id_list:
if oc_id not in form.object_classes.selected_oc.data:
... | 1,011 |
def create_ldap_quota(self, storage, group_id):
niou_cn = '{0}.G.{1}'.format(
storage,
group_id)
default_storage = self.ldap.get_default_storage(
storage).get_attributes()
add_record = [
('cn', [niou_cn]),
('objectClass', ['top', 'c... | 1,032 |
def update_users_by_file(self, edit_form, attrz_list):
fieldz = Field.query.filter(Field.id.in_(attrz_list)).all()
pre_modlist = []
for field in fieldz:
pre_modlist.append(
(field.label,
strip(getattr(edit_form, field.label).data).encode('utf-8'))... | 649 |
def generate_backup_file(self, userz, attributez):
userz = [strip(user).encode('utf-8') for user in userz.split(',')]
attributez = [strip(attribute).encode('utf-8')
for attribute in attributez.split(',')]
file_name = "backup_{0}.txt".format(
datetime.now().s... | 1,004 |
def get_next_id_from_ldap_ot(self, ldap_ot):
id_range = self.get_range_list_from_string(ldap_ot.ranges)
next_index = id_range.index(ldap_ot.last_used_id)+1
if ldap_ot.apply_to == 'group':
id_type = 'gidNumber'
else:
id_type = 'uidNumber'
while 1:
... | 866 |
def update_ldap_object_from_edit_user_form(self, form, fieldz, uid, page):
user = self.ldap.get_uid_detailz(uid)
uid_attributez = user.get_attributes()
pre_modlist = []
for field in fieldz:
form_values = [
strip(
self.converter.from_dis... | 1,012 |
and form_values
and True in form_values
):
form_values = ['1']
pre_modlist.append((field.label, form_values))
if page.label == 'ccc' and field.label == 'gidNumber':
group_cn = self.ca... | 1,002 |
self.update_user_cines_c4(user, group_cn, comite)
self.ldap.update_uid_attribute(uid, pre_modlist)
self.cache.populate_people_group()
print(u'{0} : Mise à jour de l\'utilisteur {1}'.format(
session['uid'],
uid).encode('utf-8')
) | 304 |
def upsert_otrs_user(self, uid):
user_attrz = self.ldap.get_uid_detailz(uid).get_attributes()
otrs_user = OTRSCustomerUser.query.filter_by(login = uid).first()
if not otrs_user:
otrs_user = OTRSCustomerUser(login = uid)
if 'telephoneNumber' in user_attrz:
tele... | 951 |
otrs_user.comments = '{0}; {1}'.format(user_type, first_gr_name)
otrs_user.valid_id = 1
otrs_user.create_time = datetime.now()
db.session.add(otrs_user)
db.session.commit() | 212 |
def delete_otrs_user(self, uid):
date = datetime.now().strftime("%Y%m%d%H%M")
disabled_login = "".join(['ZDEL', date, "_", uid])
# print(disabled_login)
otrs_user = OTRSCustomerUser.query.filter_by(login = uid).first()
if otrs_user:
otrs_user.login = disabled_logi... | 926 |
def update_user_table_on_deletion(self, uid):
ldap_user = self.ldap.get_uid_detailz(uid).get_attributes()
db_user = db.session.query(User).filter_by(uid=uid).first()
# Create user if doesn't already exists
if not db_user:
db_user = User(uid=uid)
db.session.add... | 835 |
def remove_user_from_all_groupz(self, uid, posix_groupz, work_groupz):
user_dn = self.ldap.get_full_dn_from_uid(uid)
for group_cn in work_groupz:
group_dn = 'cn={0},ou=grTravail,{1}'.format(
group_cn,
self.ldap_search_base
)
pre_mo... | 691 |
def set_user_submissionz(self, uid, formz):
for group in self.ldap.get_submission_groupz_list():
form = getattr(formz, group)
is_submission = form.submission.data
is_member = form.member.data
if is_submission and is_member:
self.cache.add_to_wo... | 755 |
def update_user_submission(self, uid, form):
wrk_group = strip(form.wrk_group.data)
is_submission = form.submission.data
is_member = form.member.data
if is_submission and is_member:
self.cache.add_to_work_group_if_not_member(wrk_group, [uid])
self.ldap.set_sub... | 681 |
def update_group_submission(self, form):
groupz_id = form.group_form.selected_groupz.data
groupz_infoz = [
(self.ldap.get_branch_from_posix_group_gidnumber(id),
self.cache.get_posix_group_cn_by_gid(id))
for id in groupz_id
]
groupz_memberz = self.... | 1,005 |
self.ldap.set_submission(uid, wrk_group, '0')
elif not is_member:
self.cache.rem_from_workgroup_if_member(wrk_group, groupz_memberz_uid)
for uid in groupz_memberz_uid:
self.ldap.set_submission(uid, wrk_group, '0') | 277 |
def update_ldap_object_from_edit_group_form(self, form, page, group_cn):
ldap_filter='(&(cn={0})(objectClass=posixGroup))'.format(group_cn)
attributes=['*','+']
group_attributez = self.ldap.search(
ldap_filter=ldap_filter,
attributes=attributes)[0].get_attributes()
... | 1,012 |
('memberuid',
[
member.encode('utf-8') for member in
form.memberz.selected_memberz.data
])
)
group_dn="cn={0},ou={1},ou=groupePosix,{2}".format(
group_cn,
page.label,
self.ldap_search_base)
... | 509 |
def update_ldap_object_from_edit_workgroup_form(self, form, page, group_cn):
dn="cn={0},ou=grTravail,{1}".format(
group_cn,
self.ldap_search_base)
ldap_filter='(&(cn={0})(objectClass=cinesGrWork))'.format(group_cn)
attributes=['*','+']
group_attributez = self.... | 977 |
and group_attributez[field.label] != form_field_values)):
pre_modlist.append((field.label, form_field_values))
old_memberz = group_attributez['uniqueMember']
new_memberz = [
self.ldap.get_full_dn_from_uid(member).encode('utf-8')
for member in f... | 999 |
group_cn).encode('utf-8')
) | 47 |
def update_fields_from_edit_page_admin_form(self, form, attributes, page):
Field.query.filter(Field.page_id == page.id,
~Field.label.in_(attributes)
).delete(synchronize_session='fetch')
for attribute in attributes:
attribute_field = getattr(form, attri... | 864 |
def upsert_field(self, attr_label, form_field, page):
attribute = LDAPAttribute.query.filter_by(label = attr_label).first()
field_type = FieldType.query.filter_by(
id=form_field.display_mode.data
).first()
existing_field = Field.query.filter_by(page_id=page.id,
... | 1,006 |
existing_field.block = strip(form_field.block.data)
else:
new_field = Field(label=attribute.label,
page=page,
ldapattribute=attribute,
display=form_field.display.data,
... | 825 |
def get_dict_from_raw_log_valuez(self, raw_valuez):
valuez = {}
for raw_value in raw_valuez:
# print(raw_value)
raw_value_split = raw_value.split(":")
attr_name = raw_value_split[0]
attr_operation = raw_value_split[1][:1]
attr_value = raw_v... | 1,023 |
if attr_name in valuez:
valuez[attr_name].append(
(attr_value ,
attr_operation)
)
else:
valuez[attr_name] = [(attr_value, attr_operation)]
return valuez | 301 |
def allowed_file(self, filename):
print("filename : {0}".format(filename))
print(filename.rsplit('.', 1)[1])
return '.' in filename and \
filename.rsplit('.', 1)[1] in ALLOWED_EXTENSIONS
def get_cinesdaterenew_from_uid(self, uid):
page = Page.query.filter_by(labe... | 934 |
def add_ppolicy(self, cn):
dn = "cn={0},ou=policies,ou=system,{1}".format(
cn,
self.ldap_search_base)
add_record=[('cn',[cn]),
('pwdAttribute', ['userPassword']),
('objectClass', ['device', 'pwdPolicy'])]
if self.ldap.add(dn, ad... | 518 |
# -*- coding: utf-8 -*-
# Mantid Repository : https://github.com/mantidproject/mantid
#
# Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
# NScD Oak Ridge National Laboratory, European Spallation Source
# & Institut Laue - Langevin
# SPDX - License - Identifier: GPL - 3.0 +
from __future__ impo... | 595 |
def testExecutes(self):
ws = illhelpers.create_poor_mans_d17_workspace()
illhelpers.add_flipper_configuration_D17(ws, 1, 1)
mtd.add('ws', ws)
ws = illhelpers.refl_add_line_position(ws, 128.0)
ws = illhelpers.refl_add_two_theta(ws, 6.6)
ws = illhelpers.refl_preprocess(... | 797 |
if __name__ == "__main__":
unittest.main()
| 48 |
#! /usr/bin/python
LOGICAL=["AND","OR","XOR"]
RELATIONAL=["<",">","=",'<=','>=','<>']
ADD_SUB=['+','-']
MULT=['*','/','%']
def list_statement(source):
(tokens,pos)=source
if pos>=len(tokens) or tokens[pos]=='\n':
return None
else:
ret=expression(source)
if len(source[0])>source[-1] and expect(source,','):
... | 1,026 |
def literal(token):
try:
x=float(token)
ret=True
except ValueError:
ret=False
finally:
return ret or (token.startswith('"') and token.endswith('"')) or (token.startswith("'") and token.endswith("'"))
def not_(source):
(tokens,pos)=source
if pos>=len(tokens):
raise ParseError("Expected: Identifier or Li... | 390 |
def unary_minus(source):
(tokens,pos)=source
if pos>=len(tokens):
raise ParseError("Expected: Identifier or Literal")
else:
expect(source,'-')
return ('-', factor(source))
def identifier_or_literal(source):
(tokens,pos)=source
if pos>=len(tokens):
raise ParseError("Expected: Identifier or Literal")
el... | 949 |
raise ParseError("Expected: Identifier or Literal:"+' '.join(source[0])+" got %s"%tokens[pos])
def factor(source):
(tokens,pos)=source
if pos>=len(tokens):
raise ParseException("malformed expression")
elif expect(source,'('):
ret=expression(source)
if not expect(source,')'):
raise ParseException("mal... | 1,002 |
raise ParseException("malformed expression")
def boolean(source):
(tokens,pos)=source
if pos<len(tokens):
left=value(source)
if source[-1]<len(source[0]) and source[0][source[-1]] in RELATIONAL:
mid=terminal_operator(source,RELATIONAL)
right=boolean(source)
return (mid,left,right)
else:
return l... | 770 |
def make_parse_tree(expr=[]):
source=[expr,0]
try:
return expression(source)
except ParseError,p:
print p
class ParseError(StandardError):
def __init__(self, value="Parsing Error"):
self.value=value
def __str__(self):
return self.value
if __name__=='__main__':
from sys import stdin
for line in st... | 379 |
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU... | 977 |
import time
from datetime import datetime
from dateutil.relativedelta import relativedelta
from pytz import timezone
import pytz
from openerp.osv import fields, osv
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
from openerp.tools.translate import _
class hr_timesheet_sheet(osv.o... | 715 |
res = {}
for sheet in self.browse(cr, uid, ids, context=context or {}):
res.setdefault(sheet.id, {
'total_attendance': 0.0,
'total_timesheet': 0.0,
'total_difference': 0.0,
})
for period in sheet.period_ids:
... | 580 |
def check_employee_attendance_state(self, cr, uid, sheet_id, context=None):
ids_signin = self.pool.get('hr.attendance').search(cr,uid,[('sheet_id', '=', sheet_id),('action','=','sign_in')])
ids_signout = self.pool.get('hr.attendance').search(cr,uid,[('sheet_id', '=', sheet_id),('action','=','sign_ou... | 678 |
def create(self, cr, uid, vals, context=None):
if 'employee_id' in vals:
if not self.pool.get('hr.employee').browse(cr, uid, vals['employee_id'], context=context).user_id:
raise osv.except_osv(_('Error!'), _('In order to create a timesheet for this employee, you must link him/her... | 971 |
End of preview. Expand in Data Studio
No dataset card yet
- Downloads last month
- 931