text stringlengths 6 947k | repo_name stringlengths 5 100 | path stringlengths 4 231 | language stringclasses 1
value | license stringclasses 15
values | size int64 6 947k | score float64 0 0.34 |
|---|---|---|---|---|---|---|
# ===============================================================================
# Copyright 2019 Jan Hendrickx and Gabriel Parrish
#
# 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:/... | NMTHydro/Recharge | utils/TAW_optimization_subroutine/disagg_tester.py | Python | apache-2.0 | 15,034 | 0.002993 |
# Time: O(m + n)
# Space: O(min(m, n))
# Given two arrays, write a function to compute their intersection.
#
# Example:
# Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].
#
# Note:
# Each element in the result must be unique.
# The result can be in any order.
# Hash solution.
class Solution(object):
def... | githubutilities/LeetCode | Python/intersection-of-two-arrays.py | Python | mit | 2,721 | 0.002205 |
import sys
from operator import add
from pyspark import SparkContext
if __name__ == "__main__":
if len(sys.argv) < 3:
print >> sys.stderr, \
"Usage: PythonWordCount <master> <file>"
exit(-1)
sc = SparkContext(sys.argv[1], "PythonWordCount")
lines = sc.textFile(sys.argv[2], 1)
... | koeninger/spark | python/examples/wordcount.py | Python | bsd-3-clause | 555 | 0 |
"""
Django settings for jstest project.
Generated by 'django-admin startproject' using Django 1.10.4.
For more information on this file, see
https://docs.djangoproject.com/en/1.10/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.10/ref/settings/
"""
import os
... | motobyus/moto | module_django/jstest/jstest/settings.py | Python | mit | 3,255 | 0.001536 |
# -*- coding: utf8 -*-
__author__ = 'shin'
import jieba
namelist_answer=[]
'''
namelist_answer.append('[slot_name]。')
namelist_answer.append('叫[slot_name]。')
namelist_answer.append('姓名是[slot_name]。')
namelist_answer.append('我是[slot_name]。')
namelist_answer.append('您好,我叫[slot_name]。')
namelist_answer.append('[slot_name... | shincling/MemNN_and_Varieties | DataCoupus/list_document/namelist_answer.py | Python | bsd-3-clause | 2,870 | 0.004476 |
import dircache
import os.path
from sqlalchemy import create_engine,Table,Column,Integer,String,ForeignKey,MetaData
from sqlalchemy.orm import mapper
from sqlalchemy.orm import sessionmaker
from Files import *
def SearchDirectory(session,directory,whitelist):
for file in dircache.listdir(directory):
if fil... | jenix21/DarunGrim | Src/Scripts/Test/ListDirectories.py | Python | bsd-3-clause | 1,288 | 0.045031 |
import _plotly_utils.basevalidators
class VisibleValidator(_plotly_utils.basevalidators.EnumeratedValidator):
def __init__(self, plotly_name="visible", parent_name="heatmapgl", **kwargs):
super(VisibleValidator, self).__init__(
plotly_name=plotly_name,
parent_name=parent_name,
... | plotly/python-api | packages/python/plotly/plotly/validators/heatmapgl/_visible.py | Python | mit | 517 | 0.001934 |
"""Test Ansible Syntax.
This module contains tests that validate that linter does not produce errors
when encountering what counts as valid Ansible syntax.
"""
PB_WITH_NULL_TASKS = '''
- hosts: all
tasks:
'''
def test_null_tasks(default_text_runner):
"""Assure we do not fail when encountering null tasks."""
... | willthames/ansible-lint | test/TestAnsibleSyntax.py | Python | mit | 409 | 0 |
def majority(array0):
store = {}
for i in array0:
store[i] = store.get(i,0) + 1
for i in store.keys():
if store[i] > len(array0)//2:
return i
print('No majority found')
| mindm/2017Challenges | challenge_3/python/sarcodian/src/challenge_3.py | Python | mit | 218 | 0.009174 |
# Copyright: (c) 2012, Jan-Piet Mens <jpmens () gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible.errors import AnsibleError, AnsibleAssertionError
from ansible.mo... | alexlo03/ansible | lib/ansible/utils/plugin_docs.py | Python | gpl-3.0 | 4,053 | 0.002714 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Tests for the parsers CLI arguments helper."""
import argparse
import unittest
from plaso.cli import tools
from plaso.cli.helpers import parsers
from plaso.lib import errors
from tests.cli import test_lib as cli_test_lib
class ParsersArgumentsHelperTest(cli_test_li... | log2timeline/plaso | tests/cli/helpers/parsers.py | Python | apache-2.0 | 2,477 | 0.002826 |
# -*- coding: utf-8 -*-
## This is a minimal config file for testing.
TESTING=True # this file only works in test mode
sql_driver="sqlite"
sql_database=":memory:" ## overridden when running tests
##
SECRET_KEY="fbfzkar2ihf3ulqhelg8srlzg7resibg748wifgbz478"
#TRACE=True
#MEDIA_PATH="/var/tmp/pybble"
## set by the tes... | smurfix/pybble | TEST.py | Python | gpl-3.0 | 466 | 0.038627 |
import abc
from default_metrics import DefaultMetrics
class DefaultEnvironment(object):
"""
Abstract class for environments. All environments must implement these
methods to be able to work with SBB.
"""
__metaclass__ = abc.ABCMeta
def __init__(self):
self.metrics_ = Defau... | jpbonson/SBBReinforcementLearner | SBB/environments/default_environment.py | Python | bsd-2-clause | 2,122 | 0.010839 |
#!env python
import os
import sys
sys.path.append(
os.path.join(
os.environ.get( "SPLUNK_HOME", "/opt/splunk/6.1.3" ),
"etc/apps/framework/contrib/splunk-sdk-python/1.3.0",
)
)
from collections import Counter, OrderedDict
from math import log
from nltk import tokenize
import execnet
import json
from splunkl... | nlproc/splunkml | bin/mcpredict.py | Python | apache-2.0 | 2,357 | 0.026729 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Part of the PsychoPy library
# Copyright (C) 2002-2018 Jonathan Peirce (C) 2019-2020 Open Science Tools Ltd.
# Distributed under the terms of the GNU General Public License (GPL).
"""This provides a basic ButtonBox class, and imports the
`ioLab python library <http:/... | psychopy/versions | psychopy/hardware/labjacks.py | Python | gpl-3.0 | 1,270 | 0 |
import sys
from services.spawn import MobileTemplate
from services.spawn import WeaponTemplate
from resources.datatables import WeaponType
from resources.datatables import Difficulty
from resources.datatables import Options
from java.util import Vector
def addTemplate(core):
mobileTemplate = MobileTemplate()
mobil... | agry/NGECore2 | scripts/mobiles/rori/dreaded_vir_vir.py | Python | lgpl-3.0 | 1,491 | 0.028169 |
tion for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def maxDepth(self, root):
"""
:type root: TreeNode
:rtype: int
"""
if root:
s... | Jacy-Wang/MyLeetCode | MaxDepthBinTree104Recursion.py | Python | gpl-2.0 | 678 | 0.001475 |
from django.db import models
class Writer(models.Model):
alias = models.ForeignKey('Writer', blank=True, null=True)
nick = models.CharField(unique=True, max_length=16)
class War(models.Model):
id = models.AutoField(primary_key=True)
starttime = models.DateTimeField()
endtime = models.DateTimeFie... | Venefyxatu/phennyfyxata | phennyfyxata/scores/models.py | Python | bsd-2-clause | 1,030 | 0.000971 |
from django.core.serializers.json import DjangoJSONEncoder
from django.db import models
from .fields import (
ArrayField, BigIntegerRangeField, CICharField, CIEmailField, CITextField,
DateRangeField, DateTimeRangeField, FloatRangeField, HStoreField,
IntegerRangeField, JSONField, SearchVectorField,
)
clas... | alexallah/django | tests/postgres_tests/models.py | Python | bsd-3-clause | 5,090 | 0.000393 |
'''
Created on 04.10.2012
@author: michi
'''
from PyQt4.QtCore import pyqtSignal
from ems.qt4.applicationservice import ApplicationService #@UnresolvedImport
class ModelUpdateService(ApplicationService):
objectIdsUpdated = pyqtSignal(str, list)
objectsUpdated = pyqtSignal(str)
modelUpdate... | mtils/ems | ems/qt4/services/modelupdate.py | Python | mit | 590 | 0.013559 |
# -*- coding: utf-8 -*-
# Mathmaker creates automatically maths exercises sheets
# with their answers
# Copyright 2006-2018 Nicolas Hainaux <nh.techn@gmail.com>
# This file is part of Mathmaker.
# Mathmaker is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License... | nicolashainaux/mathmaker | tests/integration/mental_calculation/04_yellow1/test_04_yellow1_multi_divi_10_100_1000.py | Python | gpl-3.0 | 1,673 | 0 |
# Copyright 2012 Nebula, 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 agree... | sandvine/horizon | horizon/forms/fields.py | Python | apache-2.0 | 15,925 | 0.000063 |
from __future__ import unicode_literals
from .. import Provider as PhoneNumberProvider
class Provider(PhoneNumberProvider):
formats = (
'+90(###)#######',
'+90 (###) #######',
'0### ### ## ##',
'0##########',
'0###-### ####',
'(###)### ####',
'### # ###',
... | deanishe/alfred-fakeum | src/libs/faker/providers/phone_number/tr_TR/__init__.py | Python | mit | 389 | 0 |
import json
import os
import sys
import unittest
import uuid
import pytest
from urllib.error import HTTPError
wptserve = pytest.importorskip("wptserve")
from .base import TestUsingServer, TestUsingH2Server, doc_root
from .base import TestWrapperHandlerUsingServer
from serve import serve
class TestFileHandler(TestU... | KiChjang/servo | tests/wpt/web-platform-tests/tools/wptserve/tests/functional/test_handlers.py | Python | mpl-2.0 | 16,970 | 0.00165 |
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2007 Zsolt Foldvari
# Copyright (C) 2008 Brian G. Matherly
# Copyright (C) 2013 Vassilii Khachaturov
#
# 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 F... | SNoiraud/gramps | gramps/plugins/docgen/cairodoc.py | Python | gpl-2.0 | 12,315 | 0.002436 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This file is part of level.
# https://github.com/heynemann/level
# Licensed under the MIT license:
# http://www.opensource.org/licenses/MIT-license
# Copyright (c) 2016, Bernardo Heynemann <heynemann@gmail.com>
from importer import Importer
from preggy import expect
fr... | heynemann/level | tests/unit/test_app.py | Python | mit | 6,332 | 0.000632 |
# -*- coding: utf-8 -*-
"""Shared model fields and defaults."""
import binascii
import os
def default_token():
"""Generate default value for token field."""
return binascii.hexlify(os.urandom(20)).decode()
| rtfd/readthedocs.org | readthedocs/core/fields.py | Python | mit | 218 | 0 |
# moosetree.py ---
#
# Filename: moosetree.py
# Description:
# Author: subhasis ray
# Maintainer:
# Created: Tue Jun 23 18:54:14 2009 (+0530)
# Version:
# Last-Updated: Sun Jul 5 01:35:11 2009 (+0530)
# By: subhasis ray
# Update #: 137
# URL:
# Keywords:
# Compatibility:
#
#
# Commentary:
#
... | BhallaLab/moose-thalamocortical | pymoose/gui/moosetree.py | Python | lgpl-2.1 | 3,777 | 0.018268 |
# -*- encoding: utf-8 -*-
{
'name': 'Account Bank Statement Import',
'category': 'Banking addons',
'version': '8.0.1.0.1',
'author': 'OpenERP SA,'
'Odoo Community Association (OCA)',
'website': 'https://github.com/OCA/bank-statement-import',
'depends': ['account'],
'data': [
... | VitalPet/bank-statement-import | account_bank_statement_import/__openerp__.py | Python | agpl-3.0 | 573 | 0 |
import os
import ycm_core
flags = [
'-Wall',
'-Wextra',
'-Werror',
'-x', 'c',
'-Iinclude',
]
# Set this to the absolute path to the folder (NOT the file!) containing the
# compile_commands.json file to use that instead of 'flags'. See here for
# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
#
... | cjhdev/lora_device_lib | vendor/cmocka/.ycm_extra_conf.py | Python | mit | 3,399 | 0.028832 |
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2015 Therp BV <http://therp.nl>.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of th... | Tecnativa/website | website_event_register_free/model/__init__.py | Python | agpl-3.0 | 1,041 | 0 |
# -*- coding: utf-8 -*-
from openerp.tests import common
class TestProjectScrum(common.TransactionCase):
def test_project_scrum(self)
env = self.env
record = env['project_scrum.0'].create({})
| mohamedhagag/community-addons | project_scrum/tests/test_project_scrum.py | Python | agpl-3.0 | 196 | 0.020408 |
from flask_wtf import Form
from wtforms import TextField, DecimalField, TextAreaField, DateField, validators, PasswordField, BooleanField
class CommentForm(Form):
text = TextField('Title', [validators.Required()])
text2 = TextAreaField('Body')
longitude = DecimalField('Longitude')
latitude = DecimalFie... | homoludens/EventMap | hello/forms.py | Python | agpl-3.0 | 1,156 | 0.006055 |
# test MicroPython-specific features of struct
try:
import ustruct as struct
except:
try:
import struct
except ImportError:
import sys
print("SKIP")
sys.exit()
class A():
pass
# pack and unpack objects
o = A()
s = struct.pack("<O", o)
o2 = struct.unpack("<O", s)
print(... | mhoffma/micropython | tests/basics/struct_micropython.py | Python | mit | 332 | 0.009036 |
"""Example code using Python threads.
Copyright 2010 Allen B. Downey
License: GNU GPLv3 http://www.gnu.org/licenses/gpl.html
"""
from threading import Thread
from time import sleep
def counter(xs, delay=1):
for x in xs:
print x
sleep(delay)
# one thread counts backwards, fast
t = Thread(target=... | simontakite/sysadmin | pythonscripts/thinkpython/thread.py | Python | gpl-2.0 | 439 | 0.006834 |
import os
import time
import json
import pprint
from util import hook
def readConfig():
### Read config json and parse it
confJson = None
with open(os.getcwd() + '/antiFloodBotConfig.json', 'r') as confFile:
confJson = confFile.read()
return json.loads(confJson)
inputs = {} #store time (uni... | mrok/ircAntiFloodBot | src/antiFloodBot.py | Python | apache-2.0 | 2,562 | 0.010929 |
import random
import unittest
from minecraftd.common import tmux_id
"""
def tmux_id(id_list):
random.seed()
new_id = random.randint(1,100)
while new_id in id_list:
new_id = random.randint(1,100)
return new_id
"""
class CommonTest(unittest.TestCase):
def setUp(self):
self.id_list =... | oldmanmike/minecraftd | minecraftd/tests/test.py | Python | gpl-3.0 | 812 | 0.002463 |
l=int(input())
d=list(input().split())
s={0:0}
for i in range(l):
for j in range(i+1,l):
diff=abs(int(d[i])-int(d[j]))
if diff not in s:
s[abs(diff)]=1
else:
s[diff]=s[diff]+1
f =lambda x:print(str(x)+" "+str(s[x]))
f(max(s.keys())) | jzcxer/0Math | python/test.py | Python | gpl-3.0 | 286 | 0.045455 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def problem05(nrlst, oplst, answer):
if len(nrlst) == 0:
return []
else:
exprlst = []
def _problem05(expr, i):
if i < len(nrlst):
for op in oplst:
_problem05(expr + op + str(nrlst[i]), i + 1)
... | koturn/FiveProgrammingProblems | Python/problem05.py | Python | mit | 602 | 0.001661 |
# -*- coding: utf-8 -*-
'''
Manage running applications.
Similar to `ps`, you can treat running applications as unix processes.
On OS X, there is a higher level Cocoa functionality (see NSApplication) which responds to events sent through the
notification center. This module operates at that level.
:maintainer: M... | mosen/salt-osx | _modules/app.py | Python | mit | 2,741 | 0.001094 |
# Copyright (C) 2007, Red Hat, Inc.
#
# 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 Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distrib... | godiard/sugar-toolkit-gtk3 | src/sugar3/graphics/animator.py | Python | lgpl-2.1 | 7,131 | 0 |
"""This module implements a loader and dumper for the svmlight format
This format is a text-based format, with one sample per line. It does
not store zero valued features hence is suitable for sparse dataset.
The first element of each line can be used to store a target variable to
predict.
This format is used as the... | huzq/scikit-learn | sklearn/datasets/_svmlight_format_io.py | Python | bsd-3-clause | 19,022 | 0.000473 |
"""
These settings act as the default (base) settings for the Sentry-provided
web-server
"""
from __future__ import absolute_import, print_function
import logging
import os.path
import six
from datetime import timedelta
from collections import OrderedDict, namedtuple
from django.conf import settings
from django.utils... | beeftornado/sentry | src/sentry/constants.py | Python | bsd-3-clause | 16,659 | 0.00102 |
#!/usr/bin/env python
# coding=utf-8
import sys
import argparse
parser = argparse.ArgumentParser(
description='convert a non-standord hostname like xx-xx-[1-3] to a '
'expansion state',
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""
Sample:
$ ./converter.py xxx-xxx-\[1-3\]
xxx-xxx-1
x... | supersu097/Mydailytools | converter.py | Python | gpl-3.0 | 905 | 0.01105 |
class Solution:
def findDuplicate(self, nums: List[int]) -> int:
slow = nums[0]
fast = nums[nums[0]]
while slow != fast:
slow = nums[slow]
fast = nums[nums[fast]]
slow2 = 0
while slow != slow2:
slow = nums[slow]
slo... | jiadaizhao/LeetCode | 0201-0300/0287-Find the Duplicate Number/0287-Find the Duplicate Number.py | Python | mit | 357 | 0.002801 |
# Copyright 2014, Doug Wiegley, A10 Networks.
#
# 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 appli... | dougwig/acos-client | acos_client/v21/partition.py | Python | apache-2.0 | 1,617 | 0 |
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from .models import Document
from .forms import DocumentForm
def list(request):
# Handle file upload
if request.method == 'POST'... | dadisigursveinn/VEF-Lokaverkefni | photos/views.py | Python | bsd-3-clause | 991 | 0.002018 |
# -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-06-20 00:54
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cs_core', '0006_auto_20160619_2151'),
]
operations = [
migrations.RemoveFiel... | wilkerwma/codeschool | src/cs_core/migrations/0007_auto_20160619_2154.py | Python | gpl-3.0 | 729 | 0.001372 |
import datetime
import unittest
from iso8601 import ParseError
from apel.parsers import BlahParser
from apel.db.records.record import InvalidRecordException
class ParserBlahTest(unittest.TestCase):
'''
Test case for LSF parser
'''
def setUp(self):
self.parser = BlahParser('testSite', 'testH... | tofu-rocketry/apel | test/test_blah.py | Python | apache-2.0 | 6,667 | 0.00855 |
#!/usr/bin/python
# Open Global Server Load Balancer (ogslb)
# Copyright (C) 2010 Mitchell Broome
#
# 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... | mbroome/ogslb | bin/backend-test.py | Python | gpl-2.0 | 2,025 | 0.017284 |
#! /usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2012-2-5
@author: zepheir
'''
import sys
sys.path.append('/app/srv/src')
from binascii import b2a_hex
try:
from twisted.internet import epollreactor
epollreactor.install()
except:
pass
from twisted.internet import reactor
from twisted.pytho... | zepheir/pySrv_sipai | srv/src/sipaiSampleServer.py | Python | apache-2.0 | 4,049 | 0.013844 |
"""Test that types defined in shared libraries work correctly."""
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class TestRealDefinition(TestBase):
mydir = TestBase.compute_mydir(__file__)
@skipUnlessDarwin
def test_frame... | endlessm/chromium-browser | third_party/llvm/lldb/test/API/lang/objc/conflicting-definition/TestConflictingDefinition.py | Python | bsd-3-clause | 1,681 | 0.000595 |
# Mustafa Hussain
# Digital Image Processing with Dr. Anas Salah Eddin
# FL Poly, Spring 2015
#
# Homework 3: Spatial Filtering
#
# USAGE NOTES:
#
# Written in Python 2.7
#
# Please ensure that the script is running as the same directory as the images
# directory!
import cv2
import copy
#import matplotlib.pyplot as p... | hmustafamail/digitalimageprocessing | HW 3 - Spatial Filtering/spatialFiltering.py | Python | gpl-2.0 | 8,567 | 0.023345 |
# -*- coding: utf-8 -*-
"""
(c) 2014-2015 - Copyright Red Hat Inc
Authors:
Pierre-Yves Chibon <pingou@pingoured.fr>
"""
import datetime
import os
import shutil
import tempfile
import uuid
import sqlalchemy
import sqlalchemy.schema
from datetime import timedelta
from sqlalchemy import func
from sqlalchemy.orm... | Devyani-Divs/pagure | pagure/lib/__init__.py | Python | gpl-2.0 | 44,784 | 0.000357 |
# Copyright (C) 2012 Hewlett-Packard Development Company, L.P.
# 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/LICEN... | Thingee/cinder | cinder/api/contrib/backups.py | Python | apache-2.0 | 13,643 | 0.000073 |
#!/usr/bin/env python
import telnetlib
import subprocess
import signal
import time
###############################################################
# This script will automatically flash and start a GDB debug
# session to the STM32 discovery board using OpenOCD. It is
# meant to be called from the rake task "debug" (... | timbrom/lightshow | scripts/flash_and_debug.py | Python | apache-2.0 | 2,657 | 0.004893 |
#########################################################################
#
# Copyright (C) 2012 OpenPlans
#
# 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
#... | RCMRD/geonode | geonode/upload/views.py | Python | gpl-3.0 | 26,130 | 0.000651 |
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 25 13:08:19 2015
@author: jgimenez
"""
from PyQt4 import QtGui, QtCore
from initialConditions_ui import Ui_initialConditionsUI
import os
from utils import *
from PyFoam.RunDictionary.BoundaryDict import BoundaryDict
from PyFoam.RunDictionary.ParsedParameterFile import P... | jmarcelogimenez/petroFoam | initialConditions.py | Python | gpl-2.0 | 6,385 | 0.010807 |
import os
import sys
import zipfile
def zip_directory(directory, targetfn=None, relative=True, compress_type=zipfile.ZIP_DEFLATED, verbose=1):
"""Zip all files and folders in a directory.
Args:
directory: The directory whose contents should be zipped.
targetfn: Output filename of the zipped a... | scholer/pptx-downsizer | pptx_downsizer/utils.py | Python | gpl-3.0 | 3,492 | 0.003436 |
import datetime
try:
import urllib.parse as urlparse
except ImportError:
from urllib.urlparse import urlparse
from django_jinja import library
from django.utils.http import urlencode
@library.global_function
def thisyear():
"""The current year."""
return datetime.date.today().year
@library.filter
d... | mozilla/lumbergh | careers/base/templatetags/helpers.py | Python | mpl-2.0 | 1,025 | 0 |
#!/usr/bin/env python
# Lint as: python3
"""Tests for PrometheusStatsCollector."""
from absl import app
from grr_response_core.stats import stats_test_utils
from grr_response_server import prometheus_stats_collector
from grr.test_lib import test_lib
class PrometheusStatsCollectorTest(stats_test_utils.StatsCollecto... | google/grr | grr/server/grr_response_server/prometheus_stats_collector_test.py | Python | apache-2.0 | 514 | 0.005837 |
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2007 Donald N. Allingham
#
# 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 you... | prculley/gramps | gramps/gen/filters/rules/person/_changedsince.py | Python | gpl-2.0 | 1,921 | 0.006247 |
# -*- coding: utf-8 -*-
#
# This file is part of Zenodo.
# Copyright (C) 2016 CERN.
#
# Zenodo 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 v... | zenodo/zenodo-migrator | zenodo_migrator/serializers/schemas/__init__.py | Python | gpl-2.0 | 1,061 | 0 |
# Copyright 2016 Virgil Dupras
#
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
# which should be included with this package. The terms are also available at
# http://www.gnu.org/licenses/gpl-3.0.html
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import (
QDialog, QLin... | tuxlifan/moneyguru | qt/controller/panel.py | Python | gpl-3.0 | 5,750 | 0.003826 |
import os
import re
import subprocess
def available_cpu_count():
""" Number of available virtual or physical CPUs on this system, i.e.
user/real as output by time(1) when called with an optimally scaling
userspace-only program"""
# cpuset
# cpuset may restrict the number of *available* processors... | macks22/nsf-award-data | util/num_cpus.py | Python | mit | 2,737 | 0 |
from __future__ import print_function
from __future__ import absolute_import
from __future__ import unicode_literals
from SimPEG import Mesh, Utils
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as patches
from scipy.sparse import spdiags,csr_matrix, eye,kron,hstack,vstack,eye,diags
impor... | geoscixyz/em_examples | em_examples/Loop.py | Python | mit | 6,800 | 0.032206 |
# -*- coding: utf-8 -*-
from fontaine.namelist import codepointsInNamelist
class Charset:
common_name = u'Google Fonts: Greek Ancient Musical Symbols'
native_name = u''
abbreviation = 'GREK'
def glyphs(self):
glyphs = codepointsInNamelist("charsets/internals/google_glyphsets/Greek/GF-greek-anc... | davelab6/pyfontaine | fontaine/charsets/internals/google_greek_ancient_musical_symbols.py | Python | gpl-3.0 | 371 | 0.008086 |
# coding: utf-8
from __future__ import absolute_import
from .base import Base
class Install(Base):
def __init__(self, config):
self.config = config
def run(self):
for package in self.config.packages:
package.install()
| hirokazumiyaji/pundler | pundler/commands/install.py | Python | mit | 258 | 0 |
##############################################################################
# Copyright (c) 2013-2018, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory.
#
# This file is part of Spack.
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
# LLNL-CODE-64... | EmreAtes/spack | var/spack/repos/builtin/packages/py-traceback2/package.py | Python | lgpl-2.1 | 1,692 | 0.001182 |
# -*- coding:utf8 -*-
from __future__ import division
import codecs
import re
def calWordProbability(infile, outfile):
'''
计算词概率,源语言词翻译成目标语言词的概率
一个源语言可能对应多个目标语言,这里计算平均值
infile: 输入文件 格式:source word \t target word
outfile: source word \t target word \t probability
'''
with codecs.open(infil... | kfeiWang/pythonUtils | wordProbability.py | Python | mit | 1,782 | 0.003064 |
# Copyright 2011-2012 Nicolas Bessi (Camptocamp)
# Copyright 2012-2015 Yannick Vaucher (Camptocamp)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields, api
class AccountInvoice(models.Model):
_inherit = 'account.invoice'
transaction_id = fields.Char(string='Transa... | OCA/bank-statement-reconcile | base_transaction_id/models/invoice.py | Python | agpl-3.0 | 1,321 | 0 |
from django.conf import settings
from django.contrib.auth.decorators import user_passes_test
from django.shortcuts import get_object_or_404
from django.utils.decorators import method_decorator
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework import filters, status, viewsets
from rest_... | pstrinkle/drf-coupons | coupons/views.py | Python | apache-2.0 | 8,022 | 0.001247 |
from .responses import CloudWatchResponse
url_bases = [
"https?://monitoring.(.+).amazonaws.com",
]
url_paths = {
'{0}/$': CloudWatchResponse.dispatch,
}
| botify-labs/moto | moto/cloudwatch/urls.py | Python | apache-2.0 | 164 | 0 |
#!/usr/bin/env python
# vim:fileencoding=utf-8
import argparse
import json
import sys
import os
def main(sysargs=sys.argv[:]):
parser = argparse.ArgumentParser()
parser.add_argument(
'instream', nargs='?', type=argparse.FileType('r'), default=sys.stdin)
parser.add_argument(
'-f', '--outpu... | meatballhat/ansible-inventory-hacks | ansible_inventory_hacks/filters/instance_filter.py | Python | mit | 1,066 | 0 |
# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).
"""Support for JavaScript and Node.js."""
from pants.build_graph.build_file_aliases import BuildFileAliases
from pants.goal.task_registrar import TaskRegistrar as task
from pants.contrib... | tdyas/pants | contrib/node/src/python/pants/contrib/node/register.py | Python | apache-2.0 | 2,805 | 0.001426 |
import nengo
from nengo.dists import Uniform
import nstbot
import numpy as np
import joystick_node
import udp
import time
use_bot = False
if use_bot:
bot = nstbot.EV3Bot()
#bot.connect(nstbot.connection.Socket('192.168.1.160'))
bot.connect(nstbot.connection.Socket('10.162.177.187'))
time.sleep(1)
... | tcstewar/ev3_demo | udp_base.py | Python | gpl-2.0 | 3,050 | 0.00623 |
import subprocess
from importlib import import_module
import os
import dolfin
import nanopores
from nanopores.tools.utilities import Log
#FIXME: deprecated because of license conflict -> import from dolfin
#from nanopores.meshconvert import convert2xml
MESHDIR = "/tmp/nanopores"
def geofile2geo(code, meta, name=None, ... | mitschabaude/nanopores | nanopores/geo2xml.py | Python | mit | 6,483 | 0.004782 |
from django.conf.urls import patterns, include, url
urlpatterns = patterns('remotestatus.views',
url(r'^remote-box/(?P<remote_box_id>[0-9]+)/$', 'remote_box_detail', name='rs-remote-box-detail'),
url(r'^(?P<call_round_id>[0-9]+)/$', 'dashboard', name='rs-dashboard'),
url(r'^$', 'dashboard', name='rs-dashbo... | cooncesean/remotestatus | remotestatus/urls.py | Python | mit | 328 | 0.009146 |
from django.core.urlresolvers import reverse, reverse_lazy
from django.http import (HttpResponseRedirect, Http404,
HttpResponsePermanentRedirect)
from django.views.generic.base import TemplateResponseMixin, View, TemplateView
from django.views.generic.edit import FormView
from django.contrib im... | sih4sing5hong5/django-allauth | allauth/account/views.py | Python | mit | 27,368 | 0.000512 |
# coding=utf8
#
"""
odtasks模块的测试用例
"""
import unittest | seraphln/onedrop | onedrop/odtasks/tests.py | Python | gpl-3.0 | 72 | 0.017241 |
def pretty_date(time=False):
"""
Get a datetime object or a int() Epoch timestamp and return a
pretty string like 'an hour ago', 'Yesterday', '3 months ago',
'just now', etc
"""
from datetime import datetime
now = datetime.now()
if type(time) is int:
diff = now - datetime.fromtim... | zellahenderson/PennApps2013 | src/prettydate.py | Python | mit | 1,307 | 0.004591 |
enlaces_iniciales = ['http://www.edutopia.org/project-based-learning-history',
'http://bie.org/about/why_pbl',
'http://es.wikipedia.org/wiki/Aprendizaje_basado_en_proyectos',
'http://en.wikipedia.org/wiki/Project-based_learning',
'https://www.youtube.com/watch?v=LMCZvGesRz8',
'http://www.learnnc.org/lp/pages/4753',
'ht... | alabarga/SocialLearning | SocialLearning/pbl.py | Python | gpl-3.0 | 1,607 | 0.009956 |
#!/usr/bin/env python2.5
"""A test provider for the stress testing."""
# change registry this often [msec]
registryChangeTimeout = 2017
from ContextKit.flexiprovider import *
import gobject
import time
import os
def update():
t = time.time()
dt = int(1000*(t - round(t)))
gobject.timeout_add(1000 - dt, ... | dudochkin-victor/contextkit | sandbox/multithreading-tests/stress-test/provider.py | Python | lgpl-2.1 | 946 | 0.013742 |
# -*- coding: utf-8 -*-
from datetime import date, datetime
from dateutil.relativedelta import relativedelta
from odoo import api, fields, models, tools, SUPERUSER_ID, _
from odoo.exceptions import AccessDenied, AccessError, UserError, ValidationError
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT as DF
from odoo... | albertosalmeronunefa/tuconsejocomunal | addons/tcc_communal_council/models/family.py | Python | gpl-3.0 | 24,178 | 0.009822 |
import contextlib
import datetime
import functools
import heapq
import time
from numbers import Number
class Timeline(object):
def __init__(self, start_time=None):
super(Timeline, self).__init__()
current_time = self._real_time()
self._forced_time = None
self._scheduled = []
... | vmalloc/flux | flux/timeline.py | Python | bsd-3-clause | 5,399 | 0.001297 |
#---------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#---------------------------------------------------------------------... | BurtBiel/azure-cli | src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_avail_set/lib/models/__init__.py | Python | mit | 1,439 | 0.00417 |
from rekall import resources
from rekall_agent import testlib
from rekall_agent.client_actions import files
from rekall_agent.client_actions import tsk
class TestTSK(testlib.ClientAcionTest):
def setUp(self):
super(TestTSK, self).setUp()
# Add a fake mount point to the image.
mount_tree_h... | dsweet04/rekall | rekall-agent/rekall_agent/client_actions/tsk_test.py | Python | gpl-2.0 | 1,298 | 0 |
#!/usr/bin/env python
from setuptools import setup, find_packages
setup(
name='hailtop',
version="0.0.1",
author="Hail Team",
author_email="hail@broadinstitute.org",
description="Top level Hail module.",
url="https://hail.is",
project_urls={
'Documentation': 'https://hail.is/docs/0... | danking/hail | hail/python/setup-hailtop.py | Python | mit | 848 | 0 |
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>
#
# This file is part of Ansible
#
# Ansible 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... | andreaso/ansible | lib/ansible/modules/system/ohai.py | Python | gpl-3.0 | 1,863 | 0.002684 |
#-------------------------------------------------------------------------------
# coding=utf8
# Name: 模块1
# Purpose:
#
# Author: zhx
#
# Created: 10/05/2016
# Copyright: (c) zhx 2016
# Licence: <your licence>
#-------------------------------------------------------------------------------
import ... | vimilimiv/weibo-popularity_judge-and-content_optimization | 数据处理/get_keyword_feature.py | Python | mit | 3,446 | 0.016007 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @first_date 20160129
# @date 20160129
# @version 0.0
"""auth for Users API
"""
from flask import abort
from flask.views import MethodView
from flask.ext.login import login_required, current_user
from sqlalchemy.exc import IntegrityError
from webargs... | pythonistas-tw/academy | web-api/tonypythoneer/db-exercise/v2/app/views/users/auth.py | Python | gpl-2.0 | 2,194 | 0.000456 |
import os
import re
import lxml.etree as etree
import subprocess
import urllib2
""" TODO: move patchwatcher in this dir """
def improvemailaddr(strings):
if '<' in strings and '>' in strings:
tmplist = strings[strings.find('<')+1:strings.find('>')].split()
retstrings = "%s@" % tmplist[0]
fi... | LuyaoHuang/patchwatcher | patchwatcher2/patchwork/patchwork.py | Python | lgpl-3.0 | 3,188 | 0.00345 |
"""
Fallback to callee definition when definition not found.
- https://github.com/davidhalter/jedi/issues/131
- https://github.com/davidhalter/jedi/pull/149
"""
"""Parenthesis closed at next line."""
# Ignore these definitions for a little while, not sure if we really want them.
# python <= 2.5
#? isinstance
isinsta... | snakeleon/YouCompleteMe-x86 | third_party/ycmd/third_party/JediHTTP/vendor/jedi/test/completion/definition.py | Python | gpl-3.0 | 1,072 | 0.028918 |
#!/usr/bin/python
""" fanhaorename.py
"""
import os
import os.path
import logging
import fileorganizer
from fileorganizer import _helper
from fileorganizer.replacename import _replacename
__author__ = "Jack Chang <wei0831@gmail.com>"
def _tagHelper(tag):
""" TODO
"""
result = ""
for c in tag:
... | wei0831/fileorganizer | fileorganizer/fanhaorename.py | Python | mit | 2,156 | 0.000928 |
"""Example of how to convert a RayTransform operator to a tensorflow layer.
This example is similar to ``tensorflow_layer_matrix``, but demonstrates how
more advanced operators, such as a ray transform, can be handled.
"""
from __future__ import print_function
import tensorflow as tf
import numpy as np
import odl
imp... | kohr-h/odl | odl/contrib/tensorflow/examples/tensorflow_layer_ray_transform.py | Python | mpl-2.0 | 1,582 | 0 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import taas.user.models
class Migration(migrations.Migration):
dependencies = [
('user', '0002_remove_username'),
]
operations = [
migrations.AlterModelManagers(
name='us... | crypotex/taas | taas/user/migrations/0003_change_user_manager.py | Python | gpl-2.0 | 447 | 0 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2013 University of Oslo, Norway
#
# This file is part of Cerebrum.
#
# Cerebrum 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 t... | unioslo/cerebrum | Cerebrum/modules/tsd/ResourceService.py | Python | gpl-2.0 | 5,210 | 0.001536 |
# -*- coding: utf_8 -*-
# Module for Malware Analysis
from urllib.parse import urlparse
import logging
import shutil
import io
import os
import re
import tempfile
import requests
from django.conf import settings
from MobSF.utils import (
PrintException,
isInternetAvailable,
upstream_proxy,
sha256
)
lo... | ajinabraham/Mobile-Security-Framework-MobSF | MalwareAnalyzer/views/domain_check.py | Python | gpl-3.0 | 4,055 | 0.002466 |
# -*- coding: utf-8 -*-
import wtforms
from werkzeug import OrderedMultiDict
from sample_data import ContactsDashboard
from flask import Flask, redirect, url_for, render_template, session, request, flash
from functools import wraps
from flask_dashed.views import get_next_or
from flask_dashed.admin import Admin
from f... | jstacoder/pycrm | level2_pycrm/__init__.py | Python | bsd-3-clause | 9,286 | 0.010015 |
__author__ = "Manuel Escriche <mev@tid.es>"
import os, pickle, base64, requests
from datetime import datetime
from kconfig import trackersBook, trackersBookByKey
from kconfig import tComponentsBook
from kernel.Jira import JIRA
class DataEngine:
class DataObject:
def __init__(self, name, storage):
... | flopezag/fiware-backlog | kernel/DataFactory.py | Python | apache-2.0 | 5,015 | 0.002991 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.