repo_name stringclasses 400
values | branch_name stringclasses 4
values | file_content stringlengths 16 72.5k | language stringclasses 1
value | num_lines int64 1 1.66k | avg_line_length float64 6 85 | max_line_length int64 9 949 | path stringlengths 5 103 | alphanum_fraction float64 0.29 0.89 | alpha_fraction float64 0.27 0.89 |
|---|---|---|---|---|---|---|---|---|---|
BlastTNG/flight | refs/heads/master | #!/usr/bin/env /usr/bin/python
import sys
import os
import os.path
#create output directory, needed before sedobjects imported
if not os.path.isdir("out"):
os.mkdir("out", 0755)
from sedobjects import *
import lineparser #provides lineparser.parse(Type, string)
defaultfile = "description.txt"
connectors = [] ... | Python | 401 | 37.735661 | 80 | /sedpy/sedparser.py | 0.671173 | 0.665186 |
BlastTNG/flight | refs/heads/master | #! /usr/bin/env python
import pylab
import Image
class Header:
pass
def parse_header(header_str):
header = Header()
header.tex_width = pylab.fromstring(header_str[4:8], "int32")[0]
header.tex_height = pylab.fromstring(header_str[8:12], "int32")[0]
header.start_char = pylab.fromstring(header_str[1... | Python | 35 | 31.857143 | 84 | /stars/code/displaying/glfont2/fonts/editing/convert_glf_to_png.py | 0.682016 | 0.64205 |
BlastTNG/flight | refs/heads/master | #! /usr/bin/env python
import os
for filename in os.listdir("."):
if filename.endswith(".ez"):
outfilename = filename.strip(".ez")
command = "ezip -d %s %s" % (filename, outfilename)
os.system(command)
| Python | 9 | 24.777779 | 59 | /stars/utilities/ebex_images/ezip_decompress_many.py | 0.596566 | 0.596566 |
BlastTNG/flight | refs/heads/master | #!/usr/bin/env /usr/bin/python
import time
import sys
import mpd
import re
import random
import pygetdata as gd
import numpy as np
#setup for the mpd connection
mpdHost = "galadriel.blast"
mpdPort = 6606
mpdPass = "250micron"
#setup for the dirfile
dirfilePath = "/data/etc/fox.lnk"
#region to song mapping
songName... | Python | 150 | 31.193333 | 95 | /singalong/singalong.py | 0.57971 | 0.560663 |
BlastTNG/flight | refs/heads/master | #! /usr/bin/env python
import pylab
import Image
class Header:
pass
def parse_header(header_str):
header = Header()
header.tex_width = pylab.fromstring(header_str[4:8], "int32")[0]
header.tex_height = pylab.fromstring(header_str[8:12], "int32")[0]
header.start_char = pylab.fromstring(header_str[1... | Python | 34 | 29.941177 | 71 | /stars/code/displaying/glfont2/fonts/editing/convert_png_to_glf.py | 0.685958 | 0.649905 |
BlastTNG/flight | refs/heads/master | #! /usr/bin/env python
import os
import sys
import pyfits
import pylab
def load_raw_data(filename):
infile = open(filename, "r")
data = pylab.fromstring(infile.read(), "uint16")
infile.close()
return data
def load_fits_data(filename):
infile = pyfits.open(filename)
data = infile[0].data.flatt... | Python | 73 | 32.863014 | 97 | /stars/utilities/ebex_images/diff_raw_with_fits.py | 0.606955 | 0.60089 |
BlastTNG/flight | refs/heads/master | #! /usr/bin/env python
import stars_log_parser
import pylab as pl
def plot_solution_fit(solution):
exaggeration = 100.0
star_xs = pl.array(map(lambda match: match.star.fitted_x, solution.matches))
star_ys = pl.array(map(lambda match: match.star.fitted_y, solution.matches))
blob_xs = pl.array(map(lambd... | Python | 28 | 40.214287 | 92 | /stars/utilities/solution_fit/plot_last_solution_fit.py | 0.656277 | 0.650216 |
youonf/location_intelligence | refs/heads/master | #!/usr/bin/env python
# coding: utf-8
# In[1]:
import requests
from bs4 import BeautifulSoup
import re
import pandas as pd
from tqdm import tqdm
import json
# In[3]:
with open('data.json', 'w') as f:
json.dump({}, f)
# In[ ]:
data={}
for j in tqdm(range(0,1843)):
url = "https://www.openrice.com/en/ho... | Python | 51 | 20.686274 | 134 | /restaurant/openrice_scraper.py | 0.610811 | 0.573874 |
youonf/location_intelligence | refs/heads/master | #!/usr/bin/env python
# coding: utf-8
# In[1]:
import requests
from bs4 import BeautifulSoup
import re
import pandas as pd
from tqdm import tqdm
import json
# In[3]:
with open('data.json') as f:
data = json.load(f)
# In[2]:
df = pd.DataFrame(columns =['name','review','bookmark','smile','sad','address','d... | Python | 54 | 29.5 | 151 | /restaurant/openrice_retrieve_json.py | 0.634161 | 0.628104 |
youonf/location_intelligence | refs/heads/master | #!/usr/bin/env python
# coding: utf-8
# In[2]:
import pandas as pd
import json
from random import randint
from time import sleep
import requests
from tqdm import tqdm
import numpy as np
# ### Clan the district, cuisine, dish columns
# In[3]:
df = pd.read_csv('restaurant_clean.csv', index_col=0)
# In[ ]:
wit... | Python | 98 | 18.67347 | 127 | /restaurant/openrice_parse_ogcio.py | 0.621047 | 0.601348 |
youonf/location_intelligence | refs/heads/master | #!/usr/bin/env python
# coding: utf-8
# In[1]:
import pandas as pd
import json
from random import randint
from time import sleep
import requests
from tqdm import tqdm
import numpy as np
# ### Clan the district, cuisine, dish columns
df = pd.read_csv('restaurant_clean.csv', index_col=0)
# In[18]:
def ogciopar... | Python | 70 | 20.557142 | 125 | /restaurant/openrice_allrestaurant.py | 0.657825 | 0.634615 |
trineary/TradeTestingEngine | refs/heads/master | # --------------------------------------------------------------------------------------------------------------------
#
# Patrick Neary
# Date: 11/12/2016
#
# Fin 5350 / Dr. Tyler J. Brough
# Trade Testing Engine:
#
# kWhiteRealityCheck.py
#
# This file is an implementation of White's Reality Check for evaluating the ... | Python | 99 | 30.252525 | 118 | /TTEBootstrapTests/WhiteBootstrap.py | 0.539406 | 0.530685 |
trineary/TradeTestingEngine | refs/heads/master | # --------------------------------------------------------------------------------------------------------------------
#
# Patrick Neary
# Date: 12/14/2016
#
# Fin 5350 / Dr. Tyler J. Brough
# Trade Testing Engine:
#
# TTEPaperEx2.py
#
# This file illustrates an example of trading rules that are engaged in a varied env... | Python | 96 | 20.614584 | 118 | /TTEPaperEx2.py | 0.578441 | 0.549567 |
trineary/TradeTestingEngine | refs/heads/master | # --------------------------------------------------------------------------------------------------------------------
#
# Patrick Neary
# Date: 11/12/2016
#
# Fin 5350 / Dr. Tyler J. Brough
# Trade Testing Engine:
#
# BootstrapCalcTools.py
#
# This file contains tools common to the bootstrap processes.
#
# -----------... | Python | 93 | 26.150537 | 118 | /TTEBootstrapTests/BootstrapCalcTools.py | 0.584951 | 0.57703 |
trineary/TradeTestingEngine | refs/heads/master | # --------------------------------------------------------------------------------------------------------------------
#
# Patrick Neary
# Date: 11/12/2016
#
# Fin 5350 / Dr. Tyler J. Brough
# Trade Testing Engine:
#
# BootstrapABC.py
#
# Abstract base class for all tests developed to evaluate rules.
#
# --------------... | Python | 44 | 23.454546 | 118 | /TTEBootstrapTests/BootstrapABC.py | 0.534323 | 0.523191 |
trineary/TradeTestingEngine | refs/heads/master | # --------------------------------------------------------------------------------------------------------------------
# Patrick Neary
# Fin5350
# Project
# 10/6/2016
#
# TradeHistory.py
#
# This file
# --------------------------------------------------------------------------------------------------------------------
... | Python | 254 | 35.748032 | 121 | /TradeTracking/TradeHistory.py | 0.574566 | 0.558603 |
trineary/TradeTestingEngine | refs/heads/master | # --------------------------------------------------------------------------------------------------------------------
#
# Patrick Neary
# Date: 11/12/2016
#
# Fin 5350 / Dr. Tyler J. Brough
# Trade Testing Engine:
#
# kWhiteRealityCheck.py
#
# This file is an implementation of White's Reality Check for evaluating the ... | Python | 150 | 30.446667 | 118 | /TTEBootstrapTests/MonteCarloBootstrap.py | 0.561798 | 0.550138 |
trineary/TradeTestingEngine | refs/heads/master | # --------------------------------------------------------------------------------------------------------------------
#
# Patrick Neary
# Date: 9/22/2016
#
# Fin 5350 / Dr. Tyler J. Brough
# Trade Testing Engine:
#
# TestFile.py
#
# This file shows how to use the TTE package
#
# ---------------------------------------... | Python | 114 | 22.289474 | 118 | /TTEExampleCode.py | 0.592954 | 0.563343 |
trineary/TradeTestingEngine | refs/heads/master | # --------------------------------------------------------------------------------------------------------------------
# Patrick Neary
# CS 6110
# Project
# 10/6/2016
#
# TradeDetails.py
#
# This file
# --------------------------------------------------------------------------------------------------------------------
... | Python | 150 | 32.246666 | 118 | /TradeTracking/TradeDetails.py | 0.532184 | 0.519551 |
trineary/TradeTestingEngine | refs/heads/master | # --------------------------------------------------------------------------------------------------------------------
#
# Patrick Neary
# Date: 9/21/2016
#
# Fin 5350 / Dr. Tyler J. Brough
# Trade Testing Engine:
#
# tte.py
#
# This file handles the interface to most of the code in this project.
#
# ------------------... | Python | 268 | 31.742537 | 119 | /TTE.py | 0.585849 | 0.574 |
trineary/TradeTestingEngine | refs/heads/master | # --------------------------------------------------------------------------------------------------------------------
#
# Patrick Neary
# Date: 12/14/2016
#
# Fin 5350 / Dr. Tyler J. Brough
# Trade Testing Engine:
#
# TTEPaperEx1.py
#
# This file shows illustrates an example of trading rules that are active during a t... | Python | 98 | 22.05102 | 118 | /TTEPaperEx1.py | 0.576923 | 0.546419 |
trineary/TradeTestingEngine | refs/heads/master |
from pytte import tte
| Python | 1 | 21 | 21 | /__init__.py | 0.72 | 0.72 |
PuppyCode0723/IMDB-crawler | refs/heads/master | #IMDB crawler
import requests
import nltk
from nltk import RegexpParser
from nltk.corpus import treebank
from nltk.corpus import sentiwordnet as swn
from lxml import html
from bs4 import BeautifulSoup
from time import sleep
import sqlite3
#遇到亂碼可以用join函數存取
con = sqlite3.connect('imdb.sqlite')
sql = 'insert into movie_c... | Python | 144 | 40.451389 | 164 | /IMDB crawler.py | 0.431346 | 0.417616 |
xiaohan2012/random_steiner_tree | refs/heads/master | import pytest
import numpy as np
from graph_tool import Graph
from random_steiner_tree import random_steiner_tree
from random_steiner_tree.util import from_gt
from collections import Counter
EPSILON = 1e-10
def graph():
"""
0 (root)
/ \
1 2
\ /
3 (X)
"""
g = Graph()
... | Python | 73 | 23.315069 | 85 | /test_loop_erased_weighted.py | 0.582535 | 0.544225 |
xiaohan2012/random_steiner_tree | refs/heads/master | import random
from .interface import loop_erased, cut_based
def random_steiner_tree(gi, X, root, method="loop_erased", seed=None, verbose=False):
assert method in {"loop_erased", "closure", "cut"}
# C++ is strict with type...
X = list(map(int, X))
root = int(root)
if seed is None:
seed = ... | Python | 18 | 30.722221 | 85 | /random_steiner_tree/__init__.py | 0.619965 | 0.597198 |
xiaohan2012/random_steiner_tree | refs/heads/master | # coding: utf-8
import networkx as nx
import numpy as np
import random
import pandas as pd
from scipy.spatial.distance import cosine
from tqdm import tqdm
from collections import Counter
from random_steiner_tree import random_steiner_tree
from random_steiner_tree.util import from_nx
from joblib import Parallel, delaye... | Python | 79 | 27.189873 | 83 | /distribution.py | 0.601257 | 0.588684 |
xiaohan2012/random_steiner_tree | refs/heads/master | # from distutils.core import setup, Extension
import os
from setuptools import setup, Extension
os.environ["CC"] = "g++"
os.environ["CXX"] = "g++"
core_module = Extension(
'random_steiner_tree/interface',
include_dirs=['/usr/include/python3.5/'],
libraries=['boost_python-py35', 'boost_graph'],
library... | Python | 29 | 30.310345 | 62 | /setup.py | 0.638767 | 0.620044 |
xiaohan2012/random_steiner_tree | refs/heads/master | import pytest
import random
import numpy as np
import networkx as nx
from graph_tool import Graph
from random_steiner_tree import random_steiner_tree
from random_steiner_tree.util import (from_nx, from_gt,
num_vertices,
isolate_vertex,
... | Python | 145 | 28.144827 | 86 | /test.py | 0.566966 | 0.547326 |
formigarafa/uroslibpy | refs/heads/master | # Copyright AF386 Group LLC 2019
import json
import logging
logger = logging.getLogger(__name__)
###############################################################################
class Message:
###########################################################################
def __init__(self, values=None):
... | Python | 177 | 32.418079 | 79 | /core.py | 0.476078 | 0.474049 |
EStepzz/LogData | refs/heads/master | #coding = utf-8
#author:QINWANG
'''
使用pyecharts 创建不同的图形图像
目前有:xxxx等图像
'''
from pyecharts import Line
from tools.ConnectDB import DbSomething
a = DbSomething('localhost','dns_query', 'postgres', 111111)
v1,v2 = a.search()
print (v1,v2)
class GenPic:
'''生成折线图'''
def lineChart(self):
line= Line("QPS图")... | Python | 25 | 17.6 | 60 | /tools/GenPic.py | 0.612069 | 0.584052 |
EStepzz/LogData | refs/heads/master | #coding=utf-8
import psycopg2
import datetime
import time
class DbSomething():
def __init__(self,ip,database,username, password,port=5432):
self.ip = ip
self.database = database
self.username = username
self.password = password
self.port = port
'''如果把connection写到__init__... | Python | 65 | 25.184616 | 77 | /tools/ConnectDB.py | 0.499706 | 0.4903 |
Bthelisma/repTravelbuddy | refs/heads/master | # -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-12-27 10:38
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('travel_app', '0002_auto_20171227_0048'),
]
operation... | Python | 30 | 39.366665 | 138 | /apps/travel_app/migrations/0003_trip.py | 0.598679 | 0.5673 |
Bthelisma/repTravelbuddy | refs/heads/master | # -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-12-27 11:20
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('travel_app', '0003_trip'),
]
operations = [
migrations.RenameField(
model... | Python | 20 | 19.9 | 46 | /apps/travel_app/migrations/0004_auto_20171227_0320.py | 0.569378 | 0.521531 |
Bthelisma/repTravelbuddy | refs/heads/master | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
import re
import bcrypt
import datetime
from django.db import models
class UserManager(models.Manager):
def register_validate(self, postData):
errors = []
name = postData['name']
username = postData['username']
passwo... | Python | 126 | 30.063492 | 80 | /apps/travel_app/models.py | 0.583802 | 0.57767 |
Bthelisma/repTravelbuddy | refs/heads/master | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.shortcuts import render, redirect
from .models import User
from .models import Trip
from django.contrib import messages
#==================================================#
# RENDER METHODS #
#===============... | Python | 90 | 26.855556 | 87 | /apps/travel_app/views.py | 0.572397 | 0.571998 |
Bthelisma/repTravelbuddy | refs/heads/master | # -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-12-27 22:55
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('travel_app', '0004_auto_20171227_0320'),
]
operations = [
migrations.AlterFie... | Python | 25 | 22.559999 | 50 | /apps/travel_app/migrations/0005_auto_20171227_1455.py | 0.565365 | 0.511036 |
devikadayanand16/todo | refs/heads/main | from django import forms
class TodoListForm(forms.Form):
text = forms.CharField(max_length=50,
widget=forms.TextInput(
attrs={'class':'form-control','placeholder':'Enter todo e.g. Grocery Shopping', 'aria-label':'Todo', 'aria-describeby':'add-btn'})) | Python | 6 | 42 | 134 | /todolist/forms.py | 0.727626 | 0.719844 |
devikadayanand16/todo | refs/heads/main | from django.db import models
class Todolist(models.Model):
text=models.CharField(max_length=50)
completed=models.BooleanField(default=False)
def __str__(self):
return self.text | Python | 7 | 25.142857 | 45 | /todolist/models.py | 0.774725 | 0.763736 |
devikadayanand16/todo | refs/heads/main | from django.shortcuts import render, redirect
from .models import Todolist
from .forms import TodoListForm
from django.views.decorators.http import require_POST
def index(request):
todo_items=Todolist.objects.order_by('id')
form = TodoListForm()
context = {'todo_items' : todo_items, 'form' : form }
return render(r... | Python | 33 | 25.848484 | 56 | /todolist/views.py | 0.751693 | 0.751693 |
morjp/py-uc_serial-protocol | refs/heads/master | #ATmega 328P Serial Protocol Host
#Version 0.1
#Compatible with client version 0.1
#Created 02/12/2019 by Moritz Prenzlow <m.prenzlow@uni-koeln.de>
#
#This host application can send packets over the serial bus to be received from the ATmega 328P and waits for a response.
#Packet structure: START BYTE (DEC 42), COMMAND ... | Python | 100 | 36.900002 | 164 | /py-uc_Serial_Protocol_0.1_Host/py-uc_Serial_Protocol_0.1_Host.py | 0.696834 | 0.665699 |
amoazeni75/multiclass-Classification-ML | refs/heads/master | # -*- coding: utf-8 -*-
"""
@author: S.Alireza Moazeni(S.A.M.P.8)
@tutorial source: Deep Learning With Python, Develop Deep Learning Models On Theano And TensorFlow Using
Keras, Jason Brownlee
"""
import numpy
import pandas
from keras.models import Sequential
from keras.layers import Dense
from keras.wrappers.scikit_l... | Python | 66 | 36.424244 | 104 | /source.py | 0.755466 | 0.744534 |
tuvm/php-iot | refs/heads/master | import paho.mqtt.client as mqtt
import random
import json
from datetime import datetime
from time import sleep
Broker = "soldier.cloudmqtt.com"
Port = 11600
Wait = 50
Topic = "datafake"
def on_connect(client, userdata, flags, rc):
if rc!=0:
pass
print('Unable connect to Broker...')
else:
print('Connected with... | Python | 56 | 26.053572 | 159 | /python/pub.py | 0.686469 | 0.656106 |
tuvm/php-iot | refs/heads/master | import MySQLdb
import json
from datetime import datetime
def Sensor(jsondata):
data = json.loads(jsondata)
mac_t = (data['mac'])
code_t = (data['code'])
value_t = (data['value'])
# time_t = datetime.now()
for i in range(0,len(code_t)):
code_i = code_t[i]
value_i = value_t[i]
conn = MySQLdb.connect("localh... | Python | 59 | 32.067795 | 126 | /python/savedata.py | 0.61917 | 0.608918 |
tuvm/php-iot | refs/heads/master | import MySQLdb
from datetime import datetime
myconn = MySQLdb.connect("localhost","root","","doan")
cur = myconn.cursor()
s1 = "DROP TABLE IF EXISTS location"
cur.execute(s1)
s2 = "DROP TABLE IF EXISTS router"
cur.execute(s2)
s3 = "DROP TABLE IF EXISTS sensor"
cur.execute(s3)
s4 = "DROP TABLE IF EXISTS sensordata... | Python | 64 | 30.390625 | 73 | /python/create.py | 0.604778 | 0.546043 |
tuvm/php-iot | refs/heads/master | import paho.mqtt.client as mqtt
import random
import json
from datetime import datetime
from time import sleep
Broker = "localhost"
Port = 1883
Wait = 45
Topic = "iot"
def on_connect(client, userdata, flags, rc):
if rc!=0:
pass
print('Unable connect to Broker...')
else:
print('Connected with Broker' + str(Bro... | Python | 54 | 21.962963 | 72 | /python/pub_manual.py | 0.697337 | 0.688458 |
tuvm/php-iot | refs/heads/master | import paho.mqtt.client as mqtt
from savedata import *
import MySQLdb
import random
import json
from datetime import datetime
from time import sleep
Broker = "soldier.cloudmqtt.com"
Port = 11600
Wait = 400
Topic = "datasensor"
Topic2 = "datafake"
def on_connect(client, userdata, flags, rc):
if rc!=0:
pass
print(... | Python | 36 | 21.722221 | 70 | /python/sub.py | 0.729829 | 0.713936 |
FUZIK/secret_punto | refs/heads/master | import tg_manager_bot.bot as manager_bot
if __name__ == '__main__':
manager_bot.main()
| Python | 4 | 22 | 40 | /main.py | 0.619565 | 0.619565 |
FUZIK/secret_punto | refs/heads/master | DATABASE_HOST = "ec2-54-247-169-129.eu-west-1.compute.amazonaws.com"
DATABASE_PORT = 5432
DATABASE_NAME = "dbm6aqb8gc2vd3"
DATABASE_USER = "lwejloxflohbkt"
DATABASE_PASSWORD = "963dca4e85ea295a09653fad768c530c2035732fd07800146d04b9ebc28186ca"
# PuntoManagerBot
MANAGER_TG_BOT_TOKEN = "1161956935:AAEelrfE2ksdxAjdanj-Uq1... | Python | 8 | 30.375 | 68 | /config.py | 0.752 | 0.664 |
FUZIK/secret_punto | refs/heads/master | import config
from peewee import PostgresqlDatabase, Model, AutoField, IntegerField, TextField, ForeignKeyField, TimestampField
from playhouse.postgres_ext import ArrayField, BlobField
_connection = PostgresqlDatabase(config.DATABASE_NAME,
host=config.DATABASE_HOST,
... | Python | 58 | 25.344828 | 113 | /core/database_adapter.py | 0.655105 | 0.655105 |
Tadaboody/good_smell | refs/heads/master | # flake8:noqa
try:
from importlib import metadata
except ImportError:
# Running on pre-3.8 Python; use importlib-metadata package
import importlib_metadata as metadata
__version__ = metadata.version("good-smell")
from .smell_warning import SmellWarning
from .lint_smell import LintSmell
from .ast_smell impo... | Python | 15 | 36.066666 | 68 | /good_smell/__init__.py | 0.78777 | 0.778777 |
Tadaboody/good_smell | refs/heads/master | import ast
from good_smell import AstSmell, LoggingTransformer
from typing import Union, Container
class RangeLenSmell(AstSmell):
@property
def transformer_class(self):
return EnumerateFixer
@property
def symbol(self):
return "range-len"
@property
def warning_message(self) -... | Python | 92 | 33.065216 | 101 | /good_smell/smells/range_len_fix.py | 0.603701 | 0.601787 |
Tadaboody/good_smell | refs/heads/master | from tests.test_collection import collect_tests, test_case_files
def generate_smell_docs():
for example_test in [list(collect_tests(file))[0] for file in test_case_files]:
desc, symbols, before, after = example_test
symbol = list(symbols)[0]
print(
f"""### {desc} ({symbol})
```... | Python | 19 | 22 | 83 | /docs/generate_smell_doc.py | 0.583524 | 0.578947 |
Tadaboody/good_smell | refs/heads/master | import abc
import ast
from typing import List, Optional, Type, TypeVar
import astor
from good_smell import LintSmell, SmellWarning
class LoggingTransformer(ast.NodeTransformer, abc.ABC):
"""A subclass of transformer that logs the nodes it transforms"""
def __init__(self, transform):
self.transformed... | Python | 62 | 28.741936 | 85 | /good_smell/ast_smell.py | 0.623644 | 0.623644 |
Tadaboody/good_smell | refs/heads/master | from typing import NamedTuple
FLAKE8_FORMAT = "{path}:{row}:{col} {symbol} {msg}"
PYLINT_FORMAT = "{path}:{line}:{column}: {msg} ({symbol})"
def to_dict(namedtuple: NamedTuple) -> dict:
return dict(zip(namedtuple._fields, list(namedtuple)))
class SmellWarning(NamedTuple):
"""Class to represent a warning me... | Python | 21 | 24 | 61 | /good_smell/smell_warning.py | 0.659048 | 0.657143 |
Tadaboody/good_smell | refs/heads/master | from .filter import FilterIterator
from .join_literal import JoinLiteral
from .nested_for import NestedFor
from .range_len_fix import RangeLenSmell
from .yield_from import YieldFrom
implemented_smells = (RangeLenSmell, NestedFor, FilterIterator, YieldFrom, JoinLiteral)
| Python | 7 | 37.714287 | 87 | /good_smell/smells/__init__.py | 0.830258 | 0.830258 |
Tadaboody/good_smell | refs/heads/master | #: example
# example-symbol,another-one
before = 0
before = 1
# ==>
after = 0
after = 1
# END
#: example
# None
before = 0
before = 1
# ==>
after = 0
after = 1
# END | Python | 16 | 9.375 | 28 | /tests/examples/example.py | 0.6 | 0.551515 |
Tadaboody/good_smell | refs/heads/master | #: Range len instead of enumerate
# range-len
for i in range(len(sequence)):
a = sequence[i]
print(a)
# ==>
for i, a in enumerate(sequence):
print(a)
# END
#: Replace an empty body with pass
# range-len
for i in range(len(sequence)):
a = sequence[i]
# ==>
for i, a in enumerate(sequence):
pass
# END
... | Python | 92 | 20.108696 | 62 | /tests/examples/range_len.py | 0.628027 | 0.622875 |
Tadaboody/good_smell | refs/heads/master | from pathlib import Path
from typing import Iterable, Type
from fire import Fire
from good_smell import LintSmell, SmellWarning, implemented_smells
def print_smell_warnings(path: str):
"""Prints any warning messages about smells"""
print(
"\n".join(
warning.warning_string()
f... | Python | 54 | 25.370371 | 79 | /good_smell/main.py | 0.615169 | 0.613764 |
Tadaboody/good_smell | refs/heads/master | from good_smell import AstSmell, LoggingTransformer
import ast
class YieldFrom(AstSmell):
"""Checks for yields inside for loops"""
@property
def transformer_class(self):
return YieldFromTransformer
@property
def warning_message(self):
return "Consider using yield from instead of ... | Python | 37 | 27.162163 | 80 | /good_smell/smells/yield_from.py | 0.648752 | 0.645873 |
Tadaboody/good_smell | refs/heads/master | #: Flatten for-loops using nested comprehensions
# nested-for
for i in seq_a:
for j in seq_b:
print(i, j)
# ==>
for i, j in ((i, j) for i in seq_a for j in seq_b):
print(i, j)
# END
#: Don't work if there's code between the loops (no way to know if it's unsafe)
# None
for i in seq_a:
print(i)
f... | Python | 66 | 20.318182 | 79 | /tests/examples/nested_for.py | 0.561478 | 0.535892 |
Tadaboody/good_smell | refs/heads/master | #: Use "yield from" instead of yield inside of a for loop
# yield-from
seq = range(10)
for x in seq:
yield x
# ==>
seq = range(10)
yield from seq
| Python | 8 | 17.75 | 57 | /tests/examples/yield_from.py | 0.653333 | 0.626667 |
Tadaboody/good_smell | refs/heads/master | import ast
import itertools
from os import PathLike
from pathlib import Path
from typing import Iterator, NamedTuple, Set
import astor
import black
import pytest
from good_smell import fix_smell, smell_warnings
FILE_DIR = Path(__file__).parent
EXAMPLES_DIR = FILE_DIR / "examples"
def normalize_formatting(code: str... | Python | 107 | 31.102804 | 87 | /tests/test_collection.py | 0.638428 | 0.636972 |
Tadaboody/good_smell | refs/heads/master | import abc
import ast
import os
from typing import List, Optional
from good_smell import SmellWarning
class LintSmell(abc.ABC):
"""Abstract Base class to represent the sniffing instructions for the linter"""
def __init__(
self,
transform: bool,
path: Optional[str] = None,
tree... | Python | 51 | 27.627451 | 84 | /good_smell/lint_smell.py | 0.618493 | 0.617808 |
Tadaboody/good_smell | refs/heads/master | import ast
import typing
from good_smell import AstSmell, LoggingTransformer
class NameInNode(LoggingTransformer):
def __init__(self, name: ast.Name):
self.name = name
super().__init__(transform=False)
def is_smelly(self, node: ast.AST) -> bool:
return isinstance(node, ast.Name) and ... | Python | 84 | 31.369047 | 88 | /good_smell/smells/nested_for.py | 0.636999 | 0.63516 |
Tadaboody/good_smell | refs/heads/master | import ast
from good_smell import AstSmell, LoggingTransformer
try:
# ast.Str is deprecated in py3.8 and will be removed
StrConst = (ast.Constant, ast.Str)
except AttributeError:
StrConst = (ast.Constant,)
class JoinLiteral(AstSmell):
"""Checks if joining a literal of a sequence."""
@property
... | Python | 70 | 31.242857 | 104 | /good_smell/smells/join_literal.py | 0.605228 | 0.600354 |
Tadaboody/good_smell | refs/heads/master | #: Warn when using join on a list of known literals.
# join-literal
a = "foo"
b = "bar"
",".join([a, b])
# ==>
a = "foo"
b = "bar"
"{},{}".format(a, b)
# END
#: Don't warn when joining an iterable
# None
iterable = ["a","b"]
",".join(iterable)
# ==>
iterable = ["a","b"]
",".join(iterable)
# END
#: Don't warn when joini... | Python | 36 | 18.527779 | 57 | /tests/examples/join_literal.py | 0.582621 | 0.55698 |
Tadaboody/good_smell | refs/heads/master | import itertools
import ast
from good_smell.smells import NestedFor
def compare_ast(node1, node2):
"""Compare two ast, adapted from https://stackoverflow.com/a/30581854 to py3"""
if type(node1) is not type(node2):
return False
if isinstance(node1, ast.AST):
for k, v in vars(node1).items():... | Python | 34 | 27.558823 | 83 | /tests/test_no_transform.py | 0.610711 | 0.585994 |
Tadaboody/good_smell | refs/heads/master | from typing import TypeVar
import ast
from typing import cast
from good_smell import AstSmell, LoggingTransformer
class NameReplacer(ast.NodeTransformer):
def __init__(self, old: ast.Name, new: ast.AST):
self.old = old
self.new = new
def visit_Name(self, node: ast.Name) -> ast.AST:
i... | Python | 85 | 30.22353 | 110 | /good_smell/smells/filter.py | 0.608515 | 0.606255 |
Tadaboody/good_smell | refs/heads/master | import ast
from typing import Generator, Tuple
from good_smell import SmellWarning, implemented_smells, __version__
class LintingFlake8:
"""Entry point good smell to be used as a flake8 linting plugin"""
name = "good-smell"
version = __version__
def __init__(self, tree: ast.AST, filename: str):
... | Python | 32 | 31.3125 | 90 | /good_smell/flake8_ext.py | 0.55029 | 0.546422 |
Tadaboody/good_smell | refs/heads/master | #: Move if to iterator
# filter-iterator
for i in range(10):
if i == 2:
print(1)
print(2)
# ==>
for i in (x for x in range(10) if x == 2):
print(1)
print(2)
# END
#: Don't move if there's code before
# None
for i in range(10):
print(1)
if pred(i):
print(2)
# ==>
for i in rang... | Python | 54 | 16.592592 | 56 | /tests/examples/filter.py | 0.529474 | 0.491579 |
Tadaboody/good_smell | refs/heads/master | from good_smell import fix_smell
from re import match
import pytest
valid_sources = ["""
a = [0]
for i in range(len(a)):
print(a[i])
""",
"""
b = [1]
for i in range(len(a + b)):
print(i)
"""]
@pytest.mark.parametrize("source", valid_sources)
def test_range_len_fix(source):
assert not mat... | Python | 20 | 18.9 | 55 | /tests/test_enumerate_fix.py | 0.557789 | 0.552764 |
1ambda/test-driven | refs/heads/master |
class TestSuite:
def __init__(self):
self.tests = []
def add(self, case):
methods = [m for m in dir(case) if callable(getattr(case, m)) if m.startswith('test')]
for m in methods:
self.tests.append(case(m))
def run(self, result):
for t in self.tests:
... | Python | 85 | 18.835295 | 94 | /xunit-python/XUnit.py | 0.525193 | 0.521636 |
1ambda/test-driven | refs/heads/master | from XUnit import *
class TestCaseSpec(TestCase):
def setUp(self):
self.result = TestResult()
def testTemplateMethod(self):
self.test = SuccessCase("testMethod")
self.test.run(self.result)
assert "setUp testMethod tearDown" == self.test.log
assert "1 run, 0 failed" =... | Python | 49 | 21.67347 | 59 | /xunit-python/XUnitSpec.py | 0.619604 | 0.610611 |
ionambrinoc/practicals | refs/heads/master | ##############################ADVANCED SECURITY PRACTICAL ASSIGNMENT 1#################################
###########################CRYPTOGRAPHY FOR PRIVACY####HILARY TERM 2015################################
#######################################################################################################
""" PRO... | Python | 25 | 36.880001 | 103 | /prac1.py | 0.475185 | 0.461457 |
ionambrinoc/practicals | refs/heads/master | ##############################ADVANCED SECURITY PRACTICAL ASSIGNMENT 1###############################
###########################CRYPTOGRAPHY FOR PRIVACY####HILARY TERM 2015##############################
"""PROTOCOL IDEA AND SPECIFICATION-------------------------------------------------------------------
0. Sam -> A... | Python | 246 | 40.548782 | 102 | /report.py | 0.633108 | 0.616965 |
ionambrinoc/practicals | refs/heads/master | ###SAMPLE CODE FOR SERVER PROCESS - "ALICE"#################################################
import socket # note that Alice is one of the participants, the one who
import sys # does not invert numbers modulo p; she acts as a server
from thread import * # for simplicity of implementation only, and this is not... | Python | 110 | 39.172726 | 92 | /alice_server.py | 0.659425 | 0.643585 |
ionambrinoc/practicals | refs/heads/master | ###SAMPLE CODE FOR ONE PROCESS - "ALICE" (NON-INVERTING)##########################################
import socket #for sockets
import sys #for exit
# generate fresh random numbers for use in protocol:
from Crypto.Util import number
rA = number.getRandomInteger(128)
rAp = number.getRandomInteger(128)
rApp= number.... | Python | 66 | 23.924242 | 98 | /alice.py | 0.684083 | 0.656744 |
ionambrinoc/practicals | refs/heads/master | ###SAMPLE CODE FOR SERVER PROCESS - "SAM"#############################################################
import socket
import sys
from thread import *
#generate random large prime (p in specification)
from Crypto.Util import number
prime = number.getPrime(512)
#generate u coprime with p; Diffie-Hellman base
u = number... | Python | 66 | 28.848484 | 102 | /sam.py | 0.656853 | 0.637056 |
ionambrinoc/practicals | refs/heads/master | ###SAMPLE CODE FOR ONE PROCESS - "BOB" (INVERTING)##########################################
import socket #for sockets
import sys #for exit
from Crypto.Util import number # generate fresh random numbers for
rB = number.getRandomInteger(128) # use in protocol;
rBp = number.getRandomInteger(128)
rBpp= num... | Python | 95 | 28.905264 | 92 | /bob.py | 0.602605 | 0.580781 |
xergio/redtorrent | refs/heads/master | # -*- coding: utf-8 -*-
import django
from django.shortcuts import render_to_response
from django.http import HttpResponse
from tracker.models import AnnounceForm, ScrapeForm, Store
import sys
import socket
import bencode
import struct
import time
import redis
"""
http://bittorrent.org/beps/bep_0003.html
http://wiki... | Python | 169 | 24.822485 | 328 | /tracker/views.py | 0.677966 | 0.590472 |
xergio/redtorrent | refs/heads/master | # -*- coding: utf-8 -*-
from django import forms
import redis
import time
class AnnounceForm(forms.Form):
info_hash = forms.CharField(max_length=100)
peer_id = forms.CharField(max_length=100)
port = forms.IntegerField()
uploaded = forms.IntegerField()
downloaded = forms.IntegerField()
left = forms.IntegerField(... | Python | 86 | 29.16279 | 73 | /tracker/models.py | 0.710557 | 0.699424 |
xergio/redtorrent | refs/heads/master | from django.conf.urls import patterns, url
urlpatterns = patterns('',
url(r'^$', 'tracker.views.announce', name='announce'),
url(r'^announce', 'tracker.views.announce', name='announce'),
url(r'^scrape$', 'tracker.views.scrape', name='scrape'),
)
| Python | 7 | 36 | 65 | /redtorrent/urls.py | 0.664093 | 0.664093 |
zaccharieramzi/tf-didn | refs/heads/master | import numpy as np
import tensorflow as tf
from didn import DIDN
def test_didn():
n_filters = 8
model = DIDN(
n_filters=n_filters,
n_dubs=2,
n_convs_recon=3,
n_scales=3,
)
model(tf.zeros((1, 64, 64, 1)))
def test_didn_change():
n_filters = 8
model = DIDN(
... | Python | 32 | 22.5 | 59 | /didn_test.py | 0.5625 | 0.535904 |
Redon913/SpaceGame | refs/heads/master | import pygame
pygame.init()
root_width = 640
root_height = 780
root = pygame.display.set_mode((root_width, root_height))
pygame.display.set_caption('SPACE ADVENTURE')
clock = pygame.time.Clock()
bg_g = pygame.transform.scale(pygame.image.load('space/space_bg1.jpg'), (640, 780))
bg_m = pygame.transform.scale(pygame.i... | Python | 328 | 31.804878 | 126 | /space_adventure.py | 0.511524 | 0.46961 |
scatteredwriter/MyPython | refs/heads/master | # coding=utf-8
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.remote.webelement import WebElement
import time
import re
def Login():
loginbut.click()
uname = driver.find_element_... | Python | 193 | 29.46114 | 107 | /study.py | 0.596344 | 0.584651 |
scatteredwriter/MyPython | refs/heads/master | # coding=utf-8
import requests
import json
import re
import os
import time
import datetime
import urllib.request
stu_num = '2015212856'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36',
'Referer': 'ht... | Python | 89 | 30.41573 | 188 | /alarm.py | 0.579549 | 0.54662 |
scatteredwriter/MyPython | refs/heads/master | # coding=utf-8
import math
courses = {
1: '电工学',
2: '高等数学(上)',
3: '大学英语3',
4: 'C语言程序设计'
}
data = {
'曽钦威': {
courses[1]: 81,
courses[2]: 77,
courses[3]: 80,
courses[4]: 95
},
'张晓阳': {
courses[1]: 75,
courses[2]: 60,
c... | Python | 99 | 24.444445 | 123 | /recommend.py | 0.496562 | 0.449962 |
scatteredwriter/MyPython | refs/heads/master | import requests
import json
import os
import platform
class Color:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
headers = {
'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; ... | Python | 181 | 40.751381 | 256 | /downloadmusic.py | 0.491068 | 0.467778 |
scatteredwriter/MyPython | refs/heads/master | # coding=utf-8
import requests
import os
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36'}
def getmusic():
url = 'http://rodvm.cloudapp.net/playmusic/playmusic.php'
result = requests.post(url, hea... | Python | 31 | 20.935484 | 136 | /playmusic.py | 0.596343 | 0.54993 |
scatteredwriter/MyPython | refs/heads/master | #coding = utf-8
import os
os.system(r'cd C:\Program Files (x86)\NetKeeper & NetKeeper.exe')
| Python | 6 | 14.833333 | 65 | /ConnectInternet/connect.py | 0.653465 | 0.623762 |
scatteredwriter/MyPython | refs/heads/master | # coding=utf-8
import requests
import json
import re
import os
import time
import urllib.request
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36'}
def gettext():
url = 'http://rodvm.cloudapp.net/br... | Python | 39 | 24.871796 | 136 | /broadcast.py | 0.625954 | 0.580153 |
scatteredwriter/MyPython | refs/heads/master | import requests
import json
def SearchStudent(searchkey):
url = 'http://jwzx.cqu.pt/data/json_StudentSearch.php?searchKey=%s'
url = url % searchkey
response = requests.get(url)
response = json.loads(response.text)
for i in range(len(response['returnData'])):
print('第%i位:姓名:%s\t年级... | Python | 39 | 31.538462 | 248 | /studentphoto.py | 0.598624 | 0.587156 |
scatteredwriter/MyPython | refs/heads/master | # coding=utf-8
from bs4 import BeautifulSoup
import requests
import re
addLists = []
dan = u''
dan2 = u''
index = -1
headers = {
'User-Agent': 'Mozilla/5.0 (Linux; Android 6.1.1; Nexus 7 Build/JRO03D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Safari/535.19',
'Referer': 'http://x... | Python | 78 | 27.012821 | 152 | /shuapiao.py | 0.536014 | 0.456032 |
scatteredwriter/MyPython | refs/heads/master | # coding=utf-8
import subprocess
subprocess.Popen(r'C:\Program Files (x86)\NetKeeper\NetKeeper.exe',0)
| Python | 5 | 20 | 69 | /test.py | 0.727273 | 0.690909 |
scatteredwriter/MyPython | refs/heads/master | # coding=utf-8
import requests
import os
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36'}
def changemusic():
url = 'http://rodvm.cloudapp.net/playmusic/changemusic.php'
result = requests.post(url... | Python | 24 | 21.166666 | 136 | /changemusic.py | 0.584532 | 0.526978 |
scatteredwriter/MyPython | refs/heads/master | import requests
import json
username = "1H<:EI 5617308362964@cqupt"
username = "%0d" + username
login_json = {"method": "do", "login": {"password": "ubc8e6wuLTefbwK"}}
response = requests.post('http://192.168.1.1', json=login_json).text
response = json.loads(response)
print(response['stok'])
dail_url = 'http://... | Python | 13 | 41.384617 | 70 | /ConnectInternet/dialer.py | 0.641844 | 0.609929 |
jewkesy/legendary-happiness | refs/heads/master | from flask import Blueprint, render_template
from emcs_admin_utils import jsplasma
runner = Blueprint('runner', __name__,
static_folder = 'static',
template_folder = 'templates')
@runner.route('/')
def base():
return render_template('runner.html', jsplasma=jsplasma) | Python | 10 | 30.1 | 60 | /web/modules/showrunner/server.py | 0.645161 | 0.645161 |
jewkesy/legendary-happiness | refs/heads/master | from flask import render_template
import os.path
from emcs_admin_utils import jsplasma
from emcs_admin_utils.flask_components import Component
#use flask because will do a lot of work for us
BASEPATH = os.path.abspath(os.path.dirname(__file__))
STATIC_PATH = os.path.join(BASEPATH, 'public')
TEMPLATES_PATH = os.path.jo... | Python | 54 | 31.074074 | 100 | /web/modules/niteworks/routes.py | 0.745812 | 0.745812 |
jewkesy/legendary-happiness | refs/heads/master | import os
from plasma import yamlio, protein
from plasma.obtypes import obmap, oblist
TREATMENT_ROOT = os.path.join(os.path.dirname(__file__), '..', '..')
COIN_BASE_DIR = "mutualVision/images/coins"
COINS_ROOT = os.path.join(TREATMENT_ROOT, 'share', COIN_BASE_DIR)
COIN_DIRS = os.listdir(COINS_ROOT)
def ingest_defaul... | Python | 231 | 27.896105 | 123 | /scripts/niteworks/generate_loan_fluoroscope.py | 0.544719 | 0.538277 |
remschira/titanic | refs/heads/master | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns; sns.set()
from sklearn.model_selection import train_test_split,cross_val_score
from sklearn.linear_model.logistic import LogisticRegression
from sklearn.metrics import confusion_matrix, accuracy_score
from sklearn.preprocessin... | Python | 311 | 39.884243 | 112 | /titanic.py | 0.573247 | 0.553207 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.