code stringlengths 3 1.05M | repo_name stringlengths 5 104 | path stringlengths 4 251 | language stringclasses 1
value | license stringclasses 15
values | size int64 3 1.05M |
|---|---|---|---|---|---|
simplelist = [1, 2, 3]
print simplelist[0]
print simplelist[1]
print simplelist[2]
stringlist = ['a string', 'b string', 'c string']
print stringlist[0]
print stringlist[1]
print stringlist[2]
emptylist = []
print emptylist
emptylist.append(1)
print emptylist
emptylist.append(2)
print emptylist
simpletuple = (1, 2, 3)
... | belenox/dmwp | Chap2.py | Python | unlicense | 3,987 |
import unittest, time, sys, random
sys.path.extend(['.','..','../..','py'])
import h2o, h2o_cmd, h2o_glm, h2o_browse as h2b, h2o_import as h2i
class Basic(unittest.TestCase):
def tearDown(self):
h2o.check_sandbox_for_errors()
@classmethod
def setUpClass(cls):
# assume we're at 0xdata with ... | 111t8e/h2o-2 | py/testdir_hosts/test_parse_summary_manyfiles_s3n_fvec.py | Python | apache-2.0 | 3,053 |
## issue: https://bugs.python.org/issue19264
import os
import ctypes
import subprocess
import _subprocess
from ctypes import byref, windll, c_char_p, c_wchar_p, c_void_p, \
Structure, sizeof, c_wchar, WinError
from ctypes.wintypes import BYTE, WORD, LPWSTR, BOOL, DWORD, LPVOID, \
HANDLE
##
## Types
##
CREA... | feinstaub/firefox_addon_local_filesystem_links | native-host/src/subprocess_fix.py | Python | gpl-2.0 | 5,272 |
"""
Sometimes, a single title is not enough, you'd like subtitles, and maybe differing
titles in the navigation and in the <title>-tag.
This extension lets you do that.
"""
from django.db import models
from django.utils.translation import ugettext_lazy as _
from feincms._internal import monkeypatch_property
def regi... | hgrimelid/feincms | feincms/module/page/extensions/titles.py | Python | bsd-3-clause | 1,504 |
#!/usr/bin/env python
import sys, os, arcpy
class GenericToolsBatchConvertRastersASCIIMXE(object):
"""This class has the methods you need to define
to use your code as an ArcGIS Python Tool."""
def __init__(self):
"""Define the tool (tool name is the name of the class)."""
se... | marbiouk/dsmtools | Tools/GenericToolsBatchConvertRastersASCIIMXE.py | Python | mit | 4,814 |
from stash.algorithms.lru import LruAlgorithm
__all__ = ['LruAlgorithm']
| fuzeman/stash.py | stash/algorithms/__init__.py | Python | mit | 74 |
#!/usr/bin/python3
import logging
from operator import itemgetter
from timeit import default_timer as timer
import rdflib
from .abstract_instruction_set import AbstractInstructionSet
from readers import rdf
from models.knowledge_graph import KnowledgeGraph
from writers import rule_set, pickler
from algorithms.semantic... | wxwilcke/MINOS | directives/pakbonLD_E3.py | Python | gpl-3.0 | 4,015 |
from setuptools import setup
setup(name='brreg_announce',
version='0.6',
description='This app scrapes the annoncements section (kunngjoringer) of Bronnoysundregistrene and returns the data on a structured format.',
url='http://github.com/anderser/brreg_announce',
author='anderser',
autho... | anderser/brreg_announce | setup.py | Python | mit | 574 |
# Copyright 2022 The Flax Authors.
#
# 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 wri... | google/flax | tests/linen/partitioning_test.py | Python | apache-2.0 | 11,156 |
"""
Unit tests for course import and export Celery tasks
"""
import copy
import json
from unittest import mock
from uuid import uuid4
from django.conf import settings
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
from django.test.utils import override_settings
from o... | eduNEXT/edunext-platform | cms/djangoapps/contentstore/tests/test_tasks.py | Python | agpl-3.0 | 6,906 |
"""
Copyright (c) 2004-Present Pivotal Software, Inc.
This program and the accompanying materials are made available under
the terms of the 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.... | Chibin/gpdb | src/test/tinc/tincrepo/mpp/gpdb/tests/storage/walrepl/load/__init__.py | Python | apache-2.0 | 1,772 |
"""Tests for the Connector Webex Teams class."""
import asyncio
import unittest
import asynctest
import asynctest.mock as amock
from opsdroid.core import OpsDroid
from opsdroid.connector.webexteams import ConnectorWebexTeams
from opsdroid.events import Message
from opsdroid.cli.start import configure_lang
class Tes... | opsdroid/opsdroid | tests/test_connector_webexteams.py | Python | apache-2.0 | 6,642 |
'''
Multi-layer arc-cosine: Vectorized version
Note: The dot product of matrices in the kernel computation will eat up so much RAM
reducing the precision of float data is a nice option. A decomposed version
of the same is coming soon.
Author: Akhil P M
'''
from sklearn import svm, datasets
from sklearn.met... | akhilpm/Masters-Project | autoencoderDLKM/mnistBackImage/arc_cosine.py | Python | mit | 3,871 |
'''
Copyright (c) <2012> Tarek Galal <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify,
m... | TeamPurple/Cyber | yowsup_dev/src/Yowsup/Registration/v1/existsrequest.py | Python | gpl-3.0 | 1,635 |
from .terminals import *
from ctypes import *
from struct import *
class ChangeType(Enum):
REMOVED = 0
ADDED = 1
class TerminalInfo:
def __init__(self, type: Terminal, signature: Signature, name: str):
self._type = type
self._signature = signature
self._name = name
@property
... | jmbergmann/yogi | yogi-python/yogi/private/node.py | Python | gpl-3.0 | 3,835 |
# See https://code.djangoproject.com/wiki/OracleTestSetup
import os
from .settings import * # noqa
DATABASES = {
"default": {
"ENGINE": "django.db.backends.oracle",
"NAME": os.environ.get("SEQUENCES_ORACLE_NAME", "127.0.0.1:1521/orcl"),
"USER": os.environ.get("SEQUENCES_ORACLE_USER", "se... | aaugustin/django-sequences | tests/oracle_settings.py | Python | bsd-3-clause | 418 |
import urwid
class PNBTreeWalker(urwid.ListWalker):
def __init__(self, start_from):
self.focus = start_from
def get_focus(self):
widget = self.focus.widget
return widget, self.focus
def set_focus(self, focus):
# TODO: here or somewhere, have focus add/remove the attrwrap for focus
self.focu... | MrAwesome/pnb | pnb/pnb_tree_walker.py | Python | gpl-3.0 | 761 |
from initdata import bob, sue
import shelve
db = shelve.open('people-shelve')
db['bob'] = bob
db['sue'] = sue
db.close()
| ordinary-developer/lin_education | books/techno/python/programming_python_4_ed_m_lutz/code/chapter_1/step_2/04_using_shelves/make_db_shelve.py | Python | mit | 122 |
from JDI.web.os_action.r_file_input import RFileInput
from JDI.web.selenium.elements.api_interact.find_element_by import By
from JDI.web.selenium.elements.common.link import Link
from JDI.web.selenium.elements.composite.web_page import WebPage
from Test.jdi_uitests_webtests.main.page_objects.sections.contact_form impor... | FunCat/JDI | Python/Test/jdi_uitests_webtests/main/page_objects/pages/dates_page.py | Python | gpl-3.0 | 646 |
#!/usr/bin/env python3
import xcdat
import os
# Prepare the dataset of keywords
keyset = xcdat.Keyset()
keyset.append('AirPods')
keyset.append('AirTag')
keyset.append('Mac')
keyset.append('MacBook')
keyset.append('MacBook_Air')
keyset.append('MacBook_Pro')
keyset.append('Mac_Mini')
keyset.append('Mac_Pro')
keyset.app... | kamp78/xcdat | pybind/sample.py | Python | mit | 1,957 |
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import tensorflow as tf
def run(a, b):
with tf.Session() as sess:
correct_prediction = tf.equal(a, b)
result = sess.run(correct_prediction)
print(result)
accuracy = tf.reduce_mean(tf.cast(correct_pred... | gdsglgf/tutorials | python/tensorflow/basic/calc.py | Python | mit | 649 |
# coding: utf-8
"""
Swaggy Jenkins
Jenkins API clients generated from Swagger / Open API specification # noqa: E501
The version of the OpenAPI document: 1.1.2-pre.0
Contact: [email protected]
Generated by: https://openapi-generator.tech
"""
import unittest
import openapi_client
from openapi_cl... | cliffano/swaggy-jenkins | clients/python-experimental/generated/test/test_hudson_master_computermonitor_data.py | Python | mit | 912 |
# -*- coding: utf-8 -*-
# Copyright 2020 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... | googleads/google-ads-python | google/ads/googleads/v9/services/types/ad_group_ad_label_service.py | Python | apache-2.0 | 5,154 |
r"""JSON (JavaScript Object Notation) <http://json.org> is a subset of
JavaScript syntax (ECMA-262 3rd edition) used as a lightweight data
interchange format.
:mod:`json` exposes an API familiar to users of the standard library
:mod:`marshal` and :mod:`pickle` modules. It is derived from a
version of the externally m... | brython-dev/brython | www/src/Lib/json.py | Python | bsd-3-clause | 11,819 |
#!/usr/bin/env python
"""
@file CSV2polyconvertXML.py
@author Daniel Krajzewicz
@author Michael Behrisch
@date 2008-07-17
@version $Id: CSV2polyconvertXML.py 22608 2017-01-17 06:28:54Z behrisch $
Converts a given CSV-file that contains a list of pois to
an XML-file that may be read by POLYCONVERT.
SUMO, Sim... | 702nADOS/sumo | tools/shapes/CSV2polyconvertXML.py | Python | gpl-3.0 | 1,565 |
from django.apps import AppConfig
class MailinglistsConfig(AppConfig):
name = 'apps.mailinglists'
verbose_name = 'Mailinglists'
| dotKom/onlineweb4 | apps/mailinglists/appconfig.py | Python | mit | 138 |
from sideloader.web.views import SideloaderView
from sideloader.db import models
class DashboardView(SideloaderView):
template_name = "index.html"
def renderData(self):
if self.request.user.is_superuser:
builds = models.Build.objects.filter(state=0).order_by('-build_time')
las... | praekeltfoundation/sideloader.web | sideloader/web/views/dashboard.py | Python | mit | 1,164 |
#coding=utf-8
import subprocess
from time import sleep
import os
import signal
import m3u8_generator
import fifo_tool
class Batch_Encoder:
def __init__(self, fifo_tool_i):
self.fifo_tool_i = fifo_tool_i
self.output_list = []
self.output_counter = 1
self.EXTINF = 1
self.media... | bowringchan/SDRRadio_Remote_Version | encoder.py | Python | gpl-3.0 | 3,025 |
# -*- coding: utf-8 -*-
"""Module containing model classes for fusions and insertions."""
# pylint: disable=wildcard-import,redefined-builtin,unused-wildcard-import
from __future__ import absolute_import, division, print_function
from builtins import *
# pylint: enable=wildcard-import,redefined-builtin,unused-wildcard... | jrderuiter/im-fusion | src/imfusion/model.py | Python | mit | 12,866 |
#!/usr/bin/env python
#encode=utf-8
#vim: tabstop=4 shiftwidth=4 softtabstop=4
#Created on 2013-8-17
#Copyright 2013 nuoqingyun xuqifeng
import datetime
import calendar
import time
from oslo.config import cfg
memcache_opts = [
cfg.ListOpt('memcached_servers',
default=['127.0.0.1:11211'],
... | homhei/glance | glance/utils/memcached.py | Python | apache-2.0 | 1,958 |
#!/usr/bin/python
import os
import os.path
import time
import datetime
import subprocess
HERE = os.path.dirname(os.path.abspath(__file__))
TICK_MINOR = os.path.join(HERE, 'coin.wav')
TICK_MAJOR = os.path.join(HERE, 'pouch.mp3')
PERIOD_MIN = 15
def play(filepath):
print 'Playing file: %s' % filepath
if not... | orlenko/TimeTracking | 15min/script/tick.py | Python | apache-2.0 | 901 |
import sqlalchemy as sa
from sqlalchemy import testing
from sqlalchemy import util
from sqlalchemy.orm import defaultload
from sqlalchemy.orm import joinedload
from sqlalchemy.orm import relationship
from sqlalchemy.orm import subqueryload
from sqlalchemy.testing import eq_
from sqlalchemy.testing.assertions import exp... | sqlalchemy/sqlalchemy | test/orm/test_default_strategies.py | Python | mit | 23,670 |
from __future__ import unicode_literals, division, absolute_import
from builtins import * # pylint: disable=unused-import, redefined-builtin
import logging
from flexget import plugin
from flexget.event import event
from flexget.plugin import PluginWarning
from flexget.config_schema import one_or_more
from flexget.ut... | poulpito/Flexget | flexget/plugins/notifiers/join.py | Python | mit | 3,468 |
# -*- coding: utf-8 -*-
###############################################################################
# (C) 2010 Oliver Gutiérrez <[email protected]>
# LOTROAssist quest items plugin
###############################################################################
# Python Imports
import re
# GTK Imports
import gtk
... | olivergs/lotroassist | src/plugins/questitems/__init__.py | Python | mit | 3,025 |
#!/usr/bin/env python
#
# Python-bindings support functions test script
#
# Copyright (C) 2008-2022, Joachim Metz <[email protected]>
#
# Refer to AUTHORS for acknowledgements.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as ... | libyal/libolecf | tests/pyolecf_test_support.py | Python | lgpl-3.0 | 3,268 |
#!/usr/bin/python
import socket
import time
import sys
import urllib2
import base64
import uuid
import json
import time
hostname = "localhost"
port = 33333
recipient_addrs = ['bob.mail2.localhost:8080@localhost:33334']
if len(sys.argv) > 1:
recipient_addrs = sys.argv[1:]
cc_addrs = []
bcc_addrs = []
subject = "... | jcnelson/syndicatemail | test/send_message.py | Python | apache-2.0 | 1,208 |
# Copyright (C) 2019 G. H. Collin (ghcollin)
#
# This software may be modified and distributed under the terms
# of the MIT license. See the LICENSE.txt file for details.
import numpy as np
from . import msgpack_ext
from .msgpack_ext import msgpack_registry
import sys
_PYTHON3 = sys.version_info > (3, 0)
if _PYTHO... | ghcollin/multitables | multitables/dataset_ops.py | Python | mit | 16,817 |
from django.db import models
from django.utils.text import slugify
# Create your models here.
class Category(models.Model):
class Meta:
verbose_name_plural = "Categories"
name = models.CharField(max_length=255)
slug = models.SlugField()
def save(self, *args, **kwargs):
if not self.id... | canibanoglu/imperial-blog | blog/models.py | Python | mit | 1,383 |
"""
An extension of the TransportCoefficients module for two-phase flow in porous media
.. inheritance-diagram:: proteus.TwophaseDarcyCoefficients
:parts: 1
"""
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
from builtins import zip
from builtins import ... | erdc/proteus | proteus/TwophaseDarcyCoefficients.py | Python | mit | 35,419 |
class Command(object):
def execute(self):
raise NotImplementedError( "Should have implemented this" )
class CachingProcess(object):
socProcesses = "#"
servicePath = None #
serviceName = None #
scales = [] #
scaleService = None
areaOfInterest = None# trumps updateExtent
# upda... | agrc/AutomatedCaching | agrc/caching/abstraction/base.py | Python | mit | 462 |
#!/bin/bash
# -*- codign:utf-8 -*-
# baseTools.fileTools.__init__
# Coded by Richard Polk
#----------------------------------------------------
# I am a package directory listed in import statements
| geosdude/baseTools | fileTools/__init__.py | Python | gpl-3.0 | 199 |
import numpy as np
import openpnm as op
from numpy.testing import assert_allclose
from openpnm.algorithms import AdvectionDiffusion, StokesFlow
import pytest
class AdvectionDiffusionTest:
def setup_class(self):
np.random.seed(0)
self.net = op.network.Cubic(shape=[4, 3, 1], spacing=1.)
sel... | PMEAL/OpenPNM | tests/unit/algorithms/AdvectionDiffusionTest.py | Python | mit | 11,095 |
# -*- coding: utf-8 -*-
import pendulum
from flexmock import flexmock, flexmock_teardown
from ... import OratorTestCase
from ...utils import MockConnection
from orator.query.builder import QueryBuilder
from orator.query.grammars import QueryGrammar
from orator.query.processors import QueryProcessor
from orator.query... | sdispater/orator | tests/orm/relations/test_morph_to_many.py | Python | mit | 6,256 |
import numpy
N = 20 #no of users
M = 10 #no of subchannels
#assume that we have a thresholding function for the rewards so that everything greater than 3*mean we will say is ACK and anything below is NACK
mean = 5
stddev = 13
RpC = numpy.random.normal(mean,stddev,M)
alpha = 0.8
gamma = 0.9
epsilon = 0.9
#def gre... | SuFizz/RL-project | stat.py | Python | gpl-3.0 | 2,299 |
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2013 Cubic ERP - Teradata SAC (<http://cubicerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the ... | jolevq/odoopub | extra-addons/account_transfer_advance/wizard/sale_advance_transfer.py | Python | agpl-3.0 | 3,218 |
import unittest
import docker
import requests.exceptions
import tempfile
import os
import shutil
import subprocess
import commands
import time
import multiprocessing
import signal
import psutil
import semantic_version
from utils.dockerutils import _fix_version
# Tests conducted with a single container running.
# docke... | sastryduri/agentless-system-crawler | tests/functional/test_functional_dockerevents.py | Python | apache-2.0 | 7,751 |
from django.db import models
from django.utils.safestring import mark_safe
from django.utils.html import format_html
# By default, Django gives each model the following field:
# id = models.AutoField(primary_key=True)
class Coordinates(models.Model):
class Meta:
unique_together = ('address', 'city', 'st... | fireplume/tennis-club | club/models.py | Python | gpl-3.0 | 7,169 |
"""Implementaton of :class:`GMPYIntegerRing` class. """
from sympy.polys.domains.integerring import IntegerRing
from sympy.polys.domains.groundtypes import (
GMPYIntegerType, SymPyIntegerType,
gmpy_factorial,
gmpy_gcdex, gmpy_gcd, gmpy_lcm, gmpy_sqrt,
)
from sympy.polys.polyerrors import CoercionFailed
... | ichuang/sympy | sympy/polys/domains/gmpyintegerring.py | Python | bsd-3-clause | 3,149 |
from __future__ import print_function
import sys
sys.path.append('..')
from src.sim import Sim
from src.packet import Packet
from networks.network import Network
class BroadcastApp(object):
def __init__(self, node):
self.node = node
def receive_packet(self, packet):
print(Sim.scheduler.cu... | zappala/bene | examples/broadcast.py | Python | gpl-2.0 | 2,081 |
"""
preHeatEx.py - (Run this before heatExchanger2.py)
Performs inital energy balance for a basic heat exchanger design
Originally built by Scott Jones in NPSS, ported and augmented by Jeff Chin
NTU (effectiveness) Method
Determine the heat transfer rate and outlet temperatures when the type ... | whiplash01/pyCycle | src/pycycle/heat_exchanger.py | Python | apache-2.0 | 4,907 |
from __future__ import unicode_literals
from django.apps import AppConfig
class PicarVConfig(AppConfig):
name = 'picar_v'
| sunfounder/SunFounder_Dragit | Dragit/Dragit/picar_v/apps.py | Python | gpl-2.0 | 129 |
from .. import app
import json
restjwt_app = app.app.test_client()
token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwcm9qZWN0IjoicmVzdGp3dCIsInByb2plY3RVcmwiOiJodHRwczovL2dpdGh1Yi5jb20vbWNrdHJ0bC9yZXN0and0In0.mBtfz91pdgOfkFLhnpB-leXmU-l3gDrAau5in3N8izE'
def test_root_correct():
endpoint = '{0}?secret=bosco'.form... | eye-ad-network/restjwt | restjwt/test/test_restjwt.py | Python | mit | 3,158 |
# -*- 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 model 'User'
db.create_table(u'pootle_user', (
(u'id... | evernote/pootle | pootle/migrations/0001_initial.py | Python | gpl-2.0 | 2,356 |
###############################################################################
# Copyright 2016 - Climate Research Division
# Environment and Climate Change Canada
#
# This file is part of the "EC-CAS diags" package.
#
# "EC-CAS diags" is free software: you can redistribute it and/or modify
# it under... | neishm/EC-CAS-diags | eccas_diags/interfaces/cccma_nc.py | Python | lgpl-3.0 | 3,833 |
import os
# Directories where data and output will be saved.
SETTINGS_DIR = os.path.abspath(os.path.dirname(__file__))
DATA_DIR = os.path.expandvars('$HOME/stormtracks_data/data')
OUTPUT_DIR = os.path.expandvars('$HOME/stormtracks_data/output')
SECOND_OUTPUT_DIR = os.path.expandvars('$HOME/stormtracks_data/output')
LO... | markmuetz/stormtracks | stormtracks/installation/settings/default_stormtracks_settings.py | Python | mit | 746 |
# -*- coding: utf-8 -*-
import unittest
from bottle import Jinja2Template, jinja2_template, jinja2_view
class TestJinja2Template(unittest.TestCase):
def test_string(self):
""" Templates: Jinja2 string"""
t = Jinja2Template('start {{var}} end').render(var='var')
self.assertEqual('start var... | BogusCurry/bottle | test/test_jinja2.py | Python | mit | 2,600 |
from . import controllers
from . import wizard
| OCA/social | mail_layout_preview/__init__.py | Python | agpl-3.0 | 47 |
###
# Copyright 2011 Diamond Light Source Ltd.
#
# 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 l... | erwindl0/python-rpc | org.eclipse.triquetrum.python.service/scripts/scisoftpy/plot.py | Python | epl-1.0 | 26,232 |
# This source file is part of the Swift.org open source project
#
# Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
# Licensed under Apache License v2.0 with Runtime Library Exception
#
# See http://swift.org/LICENSE.txt for license information
# See http://swift.org/CONTRIBUTORS.txt for the list of ... | apple/swift-llbuild | bindings/python/llbuild.py | Python | apache-2.0 | 10,444 |
from database_files.storage import DatabaseStorage
class CredAttachmentStorage(DatabaseStorage):
def url(self, name):
return 'Not used in RatticDB. If you see this please raise a bug.'
| elentarion/RatticWeb | cred/storage.py | Python | gpl-2.0 | 199 |
#!/usr/bin/env python
import struct
from elfconstants import E_TYPES, E_MACHINES, SECTION_HEADER_TYPES, \
SHT_LOOS, SHT_HIOS, SHT_LOPROC, SHT_HIPROC, SHT_LOUSER, SHT_HIUSER
"""
Class section_header
Includes information regarding a section header for an elf binary.
<Attributes>
_name: a strin... | SantiagoTorres/pydisass | readelf.py | Python | gpl-2.0 | 12,099 |
# -*- coding: utf-8 -*-
"""Provides custom exceptions for the ``cfme`` module. """
import pytest
from utils.log import logger
class CFMEException(Exception):
"""Base class for exceptions in the CFME tree
Used to easily catch errors of our own making, versus errors from external libraries.
"""
pass
... | thom-at-redhat/cfme_tests | cfme/exceptions.py | Python | gpl-2.0 | 6,738 |
# -*- coding: utf-8 -*-
import os
basedir = os.path.abspath(os.path.dirname(__file__))
class Config:
"""common configuration"""
SECRET_KEY = os.environ.get("SECRET_KEY") or "hard to guess string"
SQLALCHEMY_COMMIT_ON_TEARDOWN = True
SQLALCHEMY_RECORD_QUERIES = True
SQLALCHEMY_TRACK_MODIFICATIONS =... | kasheemlew/Sentiment_Analysis | sa/config.py | Python | apache-2.0 | 672 |
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse
from django.shortcuts import render
def home(request):
return render(request, 'home.html', {'context_var': 'expected'})
def withUrlFields(request, value):
return HttpResponse(value)
@login_required
def requiresLog... | tctimmeh/django-testing-base | testsite/testapp/views.py | Python | mit | 449 |
""" Exit Status 1 is already used in the script.
Zdd returns with exit status 1 when app is not force
deleted either through argument or through prompt.
Exit Status 2 is used for Unknown Exceptions.
"""
class InvalidArgException(Exception):
""" This exception indicates invalid combination of arguments... | matt-deboer/marathon-lb | zdd_exceptions.py | Python | apache-2.0 | 2,721 |
"""
Unit tests for mylang.parse
"""
from __future__ import absolute_import, division, print_function
from mybuild._compat import *
import ast
import itertools
import unittest
from mybuild.lang.parse import my_parse
__author__ = "Vita Loginova"
__date__ = "2015-02-02"
class ASTComparator(object):
"""
A nod... | abusalimov/mybuild | tests/test_parser.py | Python | mit | 6,463 |
#hemisample py
# For even sampling over a hemisphere
from math import pi
from numpy import sin, cos, exp, sqrt, histogram, random, zeros_like
import numpy as np
import scipy.stats as st
import numpy as np
class my_pdf(st.rv_continuous):
def _pdf(self,x):
return (pi/2.)*cos(pi*x/2.) # Normalized over its... | geocryology/HorizonPy | horizonpy/hemisample.py | Python | gpl-3.0 | 4,527 |
#!/usr/bin/env python
"""
Simple script to combine JUnit test results into a single XML file.
Useful for Jenkins.
"""
import os
import sys
from xml.etree import cElementTree as ET
def find_all(name, path):
result = []
for root, dirs, files in os.walk(path):
if name in files:
yield os.pat... | mkreider/cocotb2 | bin/combine_results.py | Python | bsd-3-clause | 1,319 |
"""
Command for dumping soft schema definitions
"""
from django.core.management.base import BaseCommand, CommandError
from django.db import connections, DEFAULT_DB_ALIAS
from django.core import serializers
from optparse import make_option
from tardis.tardis_portal import models
class Command(BaseCommand):
help... | eresearchrmit/hpctardis | tardis/tardis_portal/management/commands/dumpschemas.py | Python | bsd-3-clause | 1,683 |
import os
from bs4 import BeautifulSoup
import requests
RELEASE_STREAM = os.environ.get("RELEASE_STREAM")
def test_http_redirects_correctly():
req = requests.get("http://projectcalico.docs.tigera.io/latest")
assert req.status_code == 200
def test_latest_releases_redirects_correctly():
req = requests.g... | projectcalico/calico | calico/release-scripts/tests/test_projectcalico_docs_updated.py | Python | apache-2.0 | 547 |
from random import randint
class URLConverter(object):
char_map = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
base = len(char_map)
def to_short_string(self, id_):
short_string = ''
while id_ > 0:
short_string += self.char_map[id_ % self.base]... | rajendrauppal/coding-interview | system_design/url_shortener/short_url.py | Python | mit | 882 |
# -*- coding: utf-8 -*-
# Copyright 2012 Google 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 require... | KaranToor/MA450 | google-cloud-sdk/platform/gsutil/gslib/addlhelp/subdirs.py | Python | apache-2.0 | 7,463 |
# Copyright (C) 2013-2014 Michal Minar <[email protected]>
#
# 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 2
# of the License, or (at your option) any later version.
#
# This p... | openlmi/openlmi-doc | doc/python/lmi/scripts/_metacommand/manager.py | Python | gpl-2.0 | 6,216 |
#!/usr/bin/env python
# This work was created by participants in the DataONE project, and is
# jointly copyrighted by participating institutions in DataONE. For
# more information on DataONE, see our web site at http://dataone.org.
#
# Copyright 2009-2019 DataONE
#
# Licensed under the Apache License, Version 2.0 (t... | DataONEorg/d1_python | client_onedrive/src/d1_onedrive/impl/resolver/d1_object.py | Python | apache-2.0 | 6,349 |
"""
Testing POSTs to "/submission" using submission-time validation
"""
import os
from main.tests.test_base import MainTestCase
from unittest.case import skip
class TestSubmissionTime_validation(MainTestCase):
def setUp(self):
MainTestCase.setUp(self)
xls_file_path = os.path.join(
os.... | eHealthAfrica/formhub | odk_logger/tests/test_submissionTime_validation.py | Python | bsd-2-clause | 1,277 |
import ConfigParser
import StringIO
def basic(src):
print
print "Testing basic accessors..."
cf = ConfigParser.ConfigParser()
sio = StringIO.StringIO(src)
cf.readfp(sio)
L = cf.sections()
L.sort()
print L
for s in L:
print "%s: %s" % (s, cf.options(s))
# The use of spac... | kidmaple/CoolWall | user/python/Lib/test/test_cfgparser.py | Python | gpl-2.0 | 4,272 |
# This work is copyright 2011 - 2013 Jordon Mears. All rights reserved.
#
# This file is part of Cider.
#
# Cider 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 op... | jordoncm/cider | options.py | Python | gpl-3.0 | 1,324 |
from unittest import TestCase
from configcascade import Settings, YamlFileLoader
import os
class SettingsTestCase(TestCase):
def test_with_merge(self):
config_file = os.path.realpath("%s/fixture/config/settings_test.yml" % os.path.dirname(os.path.realpath(__file__)))
file_loader = YamlFileLoader()... | felixcarmona/configcascade | configcascade/tests/test_settings.py | Python | mit | 3,062 |
import sys
from ahkab import main, options
options.cli = True
main(sys.argv[1], verbose=3, outfile='tmp')
| ahkab/ahkab | misc/dbg.py | Python | gpl-2.0 | 106 |
import unittest
from simple_linked_list import LinkedList, EmptyListException
# No canonical data available for this exercise
class SimpleLinkedListTest(unittest.TestCase):
def test_empty_list_has_len_zero(self):
sut = LinkedList()
self.assertEqual(len(sut), 0)
def test_singleton_list_has_l... | jmluy/xpython | exercises/practice/simple-linked-list/simple_linked_list_test.py | Python | mit | 3,873 |
import pygame
import dinosInSpace
import random
import math
import fpsSwitch
ABSOLUTE_BOUNDS = ((400 + 50, 0), (800 - 50, 600)) # topleft, bottomright
FRAME_DELAY = 10
SPIN_RANGE = 3
SPEED = (0,2)
class TitleDino(pygame.sprite.Sprite):
""" top to bottom wrapping, regenerating dino sprite specifically ... | sabajt/Dinos-In-Space | titleDino.py | Python | mit | 4,163 |
import unittest
import transaction
from pyramid import testing
from .models import DBSession
class TestMyView(unittest.TestCase):
def setUp(self):
self.config = testing.setUp()
from sqlalchemy import create_engine
engine = create_engine('sqlite://')
from .models import (
... | bjornsen/MoreResults | moreresults/tests.py | Python | agpl-3.0 | 882 |
# -*- coding: utf-8 -*-
import werobot
robot = werobot.WeRoBot(token='tokenhere')
@robot.text
def hello_world(message):
return 'Hello World!'
@robot.filter("帮助")
def show_help(message):
return """
帮助
XXXXX
"""
robot.run() | yangdw/PyRepo | src/annotation/WeRoBot/example/hello_world.py | Python | mit | 254 |
from .resource import Resource
class Link(Resource):
def __init__(self, href, title):
super().__init__()
self.href = href
self.title = title
@classmethod
def parse_from_json_object(cls, json_object):
href = json_object.get('href')
title = json_object.get('title')
... | bitmovin/bitmovin-python | bitmovin/resources/link.py | Python | unlicense | 385 |
"""
worldfolder
"""
from __future__ import absolute_import, division, print_function, unicode_literals
from collections import defaultdict
import logging
from mceditlib.exceptions import ChunkNotPresent
log = logging.getLogger(__name__)
from mceditlib.pc.regionfile import RegionFile
import os
class AnvilWorldFo... | Rubisk/mcedit2 | src/mceditlib/anvil/worldfolder.py | Python | bsd-3-clause | 7,916 |
#!/home/ubuntu/Cinemiezer/myvenv/bin/python3
# $Id: rst2html.py 4564 2006-05-21 20:44:42Z wiemann $
# Author: David Goodger <[email protected]>
# Copyright: This module has been placed in the public domain.
"""
A minimal front end to the Docutils Publisher, producing HTML.
"""
try:
import locale
locale.setl... | arnavd96/Cinemiezer | myvenv/bin/rst2html.py | Python | mit | 620 |
# BitDefender Online Scanner ActiveX Control
# CVE-2007-5775
import logging
log = logging.getLogger("Thug")
def initx(self, arg):
if len(arg) > 1024:
log.ThugLogging.log_exploit_event(self._window.url,
"BitDefender Online Scanner ActiveX",
... | tweemeterjop/thug | thug/ActiveX/modules/BitDefender.py | Python | gpl-2.0 | 423 |
# -*- coding: utf-8 -*-
#BEGIN_HEADER
import os
import requests
from hipmer.hipmerUtils import hipmerUtils
import requests.packages.urllib3
requests.packages.urllib3.disable_warnings()
#END_HEADER
class hipmer:
'''
Module Name:
hipmer
Module Description:
A KBase module: hipmer
'''
#####... | kbaseapps/kbase_hipmer | lib/hipmer/hipmerImpl.py | Python | mit | 2,416 |
# encoding: utf-8
import datetime
import os
from south.db import db
from south.v2 import DataMigration
from django.db import models
import askbot
from askbot.utils.console import ProgressBar
from askbot.search.postgresql import setup_full_text_search
class Migration(DataMigration):
def forwards(self, orm):
... | maxwward/SCOPEBak | askbot/migrations/0137_create_groups_from_relevant_tags.py | Python | gpl-3.0 | 36,997 |
import os,os.path,shutil
import numpy as np
import pickle
import dmdd
import dmdd_efficiencies as eff
def check_min_mass(element='fluorine', Qmin=1., v_esc=544., v_lag=220., mx_guess=1.):
experiment = dmdd.Experiment('test',element,Qmin, 40.,100., eff.efficiency_unit)
res = experiment.find_min_mass(v_esc=v_e... | veragluscevic/dmdd | dmdd/tests/test.py | Python | mit | 8,718 |
from typing import Optional
import numbers
from math import atan2, degrees
def mod360(
val: numbers.Real
) -> numbers.Real:
"""
Return the module 360 of the originila value.
:param val: value.
:type val: numbers.Real.
:return: value divided by mod 360.
:rtype: numbers.Real.
Ex... | mauroalberti/gsf | pygsf/orientations/direct_utils.py | Python | gpl-3.0 | 4,980 |
from datetime import datetime
import json
from django.conf import settings
from django.contrib.auth.models import AnonymousUser
from mock import Mock, patch
from multidb import this_thread_is_pinned
from nose.tools import eq_, ok_
from tastypie.exceptions import ImmediateHttpResponse
from access.models import Group,... | Joergen/zamboni | mkt/api/tests/test_authentication.py | Python | bsd-3-clause | 10,988 |
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
"""
:samp:`Pluggable resource gate and builder`
Build your own
--------------
The selection mechanism for resources is implemented as a :func:`~rspub.util.gates.gate` that uses
predicates for including and excluding resources based on their filename.
The :class:`~rspub.... | cegesoma/rspub-core | rspub/pluggable/gate.py | Python | apache-2.0 | 5,977 |
from __future__ import print_function
"""
Part of Cosmos by OpenGenus Foundation
"""
matrix = lambda x: list(map(list, zip(*[iter(range(1, x * x + 1))] * x)))
"""
matrix = [
[1, 2, 3, 4, 5],
[6, 7, 8, 9, 10],
[11, 12, 13, 14, 15],
[16, 17, 18, 19, 20],
[21, 22, 23, 24, 25]
]
"""
def main(size):
a = matrix(size)... | OpenGenus/cosmos | code/unclassified/src/spiral_print/spiral_print.py | Python | gpl-3.0 | 973 |
import sys
from easy.visitors.base import BaseVisitor
class IncIndent(object):
def __init__(self, pprint):
self._pprint = pprint
def __enter__(self):
self._pprint._indent += 1
def __exit__(self, *args):
self._pprint._indent -= 1
class PPrintVisitor(BaseVisitor):
def __init__... | helgefmi/Easy | src/easy/visitors/pprint.py | Python | mit | 2,821 |
# Copyright (C) 2018 Alexandre Morlet, Fulvio Paleari, Henrique Pereira Coutada Miranda
# All rights reserved.
#
# This file is part of yambopy
#
from __future__ import print_function
from builtins import zip
from builtins import map
from builtins import range
from yamboparser import *
from os import *
import argparse
... | alexmoratalla/yambopy | scripts/add_qp.py | Python | bsd-3-clause | 7,433 |
#!/usr/bin/env python
from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup
d = generate_distutils_setup(
## don't do this unless you want a globally visible script
# scripts=['bin/robbie'],
packages=['robbie'],
package_dir={'': 'src'}
)
setup(**d)
| peterheim1/robbie | setup.py | Python | gpl-3.0 | 307 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3 as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; ... | rubenspgcavalcante/Config-Loader | setup.py | Python | gpl-3.0 | 1,350 |
# -*- coding: utf-8; -*-
#
# Licensed to Crate (https://crate.io) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. Crate licenses
# this file to you under the Apache License, Version 2.0 (the "License");
# yo... | crate/crate-web | plugins/haml.disabled.py | Python | apache-2.0 | 1,980 |
import re
import datetime
import logging
log = logging.getLogger(__name__)
class Marker(object):
__slots__ = ['line_start', 'line_end', 'expires']
def __init__(self, lineno):
self.line_start = lineno
self.line_end = lineno
self.expires = None
def __str__(self):
if self.l... | jimmyshen/sunset | sunset/parser.py | Python | mit | 2,091 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.