repo_name stringlengths 6 97 | path stringlengths 3 341 | text stringlengths 8 1.02M |
|---|---|---|
5703863336/electriity | meiduo_mall/apps/oauth/views.py | <filename>meiduo_mall/apps/oauth/views.py<gh_stars>0
import re
from django.contrib.auth import login
from django.http import HttpResponseBadRequest
from django.shortcuts import render, redirect
from django_redis import get_redis_connection
from apps.oauth.utils import serect_openid, check_openid
# Create your views h... |
5703863336/electriity | meiduo_mall/apps/users/views.py | import json
from django.contrib.auth import login, logout, authenticate
from django.contrib.auth.mixins import LoginRequiredMixin
from django.http import HttpResponse
from django.http import HttpResponseBadRequest
from django.http import JsonResponse
from django.shortcuts import render, redirect
import re
import loggi... |
5703863336/electriity | meiduo_mall/apps/carts/utils.py | <reponame>5703863336/electriity
import base64
import pickle
from django_redis import get_redis_connection
def merge_cookie_to_redis(request,user,response):
"""
1.获取cookie数据
2.把redis数据读取下来
初始化一个字典
一个列表用于记录选中的id
一个列表用于记录未选中的id
3. 对cookie数据进行遍历
4.将合并的数据更新到red... |
5703863336/electriity | meiduo_mall/apps/users/urls.py | from django.conf.urls import url, include
from django.contrib import admin
from django.http.response import HttpResponse
from apps.users import views
urlpatterns = [
url(r'^register/$',views.RegisterView.as_view(),name='register'),
url(r'^usernames/(?P<username>[a-zA-Z0-9_-]{5,20})/$',views.isUnique.as_view... |
5703863336/electriity | meiduo_mall/apps/verifications/views.py | <reponame>5703863336/electriity
import json
from django.http import HttpResponse,HttpResponseBadRequest
from django.http import JsonResponse
from django.shortcuts import render
from random import randint
# Create your views here.
from django.views import View
from apps.users.utils import check_access_token_token
fro... |
DalavanCloud/llvm-lnt | lnt/server/config.py | <filename>lnt/server/config.py<gh_stars>1-10
"""
LNT Config object for tracking user-configurable installation parameters.
"""
import os
import re
import tempfile
import lnt.server.db.v4db
class EmailConfig:
@staticmethod
def from_data(data):
# The email to field can either be a string, or a list of... |
ggirelli/tiff-tools-gg | src/conversion/nd2toTif.py | <reponame>ggirelli/tiff-tools-gg<gh_stars>0
#!/usr/bin/env python
def convert(path, startJvm=True, killJvm=True):
'''
Provided the path to the directory containing the nd2 files, they will be
converted to tif format.
Provided the path to a nd2 file, it will be converted to tif format.
'''
import bioformats
imp... |
Babakjfard/COVID | src/visualization/make_shapefile.py | # I have downloaded ACS 5 year estimate 2017 - Table B01001
# I have downloaded TIGER shape file of NE- BG level
import numpy as np
import pandas as pd
import geopandas as gpd
import re
def abbreviate(word):
#print(word)
a1 = re.sub('[a-z]*;\s', '_', word)
a2 = a1.replace(': - ','_')
a3 = a2.replace('... |
Babakjfard/COVID | setup.py | <reponame>Babakjfard/COVID
from setuptools import find_packages, setup
setup(
name='src',
packages=find_packages(),
version='0.1.0',
description='Anything realted to the visualization and data analysis of COVID-19',
author='Babakjfard',
license='MIT',
)
|
Babakjfard/COVID | src/visualization/GlobalHealth.py | <gh_stars>0
# Mar 06, 2020 - <NAME>
# The code for creating time series plots and global animated map of corona virus spread
#
import numpy as np
import geopandas as gpd
import pandas as pd
from functools import reduce
#### Part 1 : Preparing the data
# 1.1 Downloading csv into dataframe
df_confirmed = pd.read_csv... |
ocurero/bpython | bpython/test/test_curtsies_painting.py | <filename>bpython/test/test_curtsies_painting.py
import itertools
import os
import pydoc
import string
import sys
from contextlib import contextmanager
from curtsies.formatstringarray import (
fsarray,
assertFSArraysEqual,
assertFSArraysEqualIgnoringFormatting,
)
from curtsies.fmtfuncs import cyan, bold, g... |
ikilledthecat/marshmallow | marshmallow/utils.py | # -*- coding: utf-8 -*-
"""Utility methods for marshmallow."""
from __future__ import absolute_import, unicode_literals
import collections
import functools
import datetime
import inspect
import json
import re
import time
import types
import warnings
from calendar import timegm
from decimal import Decimal, ROUND_HALF_E... |
raoulcollenteur/flopy | flopy/mf6/data/mfdatalist.py | from collections import OrderedDict
import math
import sys
import inspect
import numpy as np
from ..utils.mfenums import DiscretizationType
from ..data import mfstructure, mfdata
from ..mfbase import MFDataException, ExtFileAction
from .mfstructure import DatumType
from ...utils import datautil
from ...datbas... |
raoulcollenteur/flopy | flopy/mf6/modflow/mfgwfgwf.py | <gh_stars>1-10
# DO NOT MODIFY THIS FILE DIRECTLY. THIS FILE MUST BE CREATED BY
# mf6/utils/createpackages.py
from .. import mfpackage
from ..data.mfdatautil import ListTemplateGenerator
class ModflowGwfgwf(mfpackage.MFPackage):
"""
ModflowGwfgwf defines a gwfgwf package.
Parameters
-----... |
raoulcollenteur/flopy | flopy/modflow/mfflwob.py | <reponame>raoulcollenteur/flopy
import numpy as np
from ..pakbase import Package
class ModflowFlwob(Package):
"""
Head-dependent flow boundary Observation package class. Minimal working
example that will be refactored in a future version.
Parameters
----------
nqfb : int
N... |
raoulcollenteur/flopy | flopy/mf6/modflow/mfgwfdisv.py | <filename>flopy/mf6/modflow/mfgwfdisv.py
# DO NOT MODIFY THIS FILE DIRECTLY. THIS FILE MUST BE CREATED BY
# mf6/utils/createpackages.py
from .. import mfpackage
from ..data.mfdatautil import ArrayTemplateGenerator, ListTemplateGenerator
class ModflowGwfdisv(mfpackage.MFPackage):
"""
ModflowGwfdisv de... |
raoulcollenteur/flopy | flopy/discretization/unstructuredgrid.py | <gh_stars>1-10
import numpy as np
from .grid import Grid, CachedData
class UnstructuredGrid(Grid):
"""
Class for an unstructured model grid
Parameters
----------
vertices
list of vertices that make up the grid
cell2d
list of cells and their vertices
Propert... |
raoulcollenteur/flopy | flopy/mf6/modflow/mfutlobs.py | <gh_stars>1-10
# DO NOT MODIFY THIS FILE DIRECTLY. THIS FILE MUST BE CREATED BY
# mf6/utils/createpackages.py
from .. import mfpackage
from ..data.mfdatautil import ListTemplateGenerator
class ModflowUtlobs(mfpackage.MFPackage):
"""
ModflowUtlobs defines a obs package within a utl model.
Param... |
raoulcollenteur/flopy | flopy/mf6/modflow/__init__.py | <reponame>raoulcollenteur/flopy
# imports
from .mfsimulation import MFSimulation
from .mfnam import ModflowNam
from .mftdis import ModflowTdis
from .mfgwfgwf import ModflowGwfgwf
from .mfims import ModflowIms
from .mfmvr import ModflowMvr
from .mfgnc import ModflowGnc
from .mfutlobs import ModflowUtlobs
from .... |
hoefling/pytest-mypy-plugins | pytest_mypy_plugins/tests/reveal_type_hook.py | from pytest_mypy_plugins.item import YamlTestItem
def hook(item: YamlTestItem) -> None:
parsed_test_data = item.parsed_test_data
obj_to_reveal = parsed_test_data.get("reveal_type")
if obj_to_reveal:
for file in item.files:
if file.path.endswith("main.py"):
file.content ... |
hoefling/pytest-mypy-plugins | pytest_mypy_plugins/item.py | import importlib
import os
import subprocess
import sys
import tempfile
from configparser import ConfigParser
from pathlib import Path
from typing import Any, Callable, Dict, List, Optional, Tuple
import pytest
from _pytest._code import ExceptionInfo
from _pytest._code.code import ReprEntry, ReprFileLocation
from _pyt... |
nimrody15/cyberark-aws-auto-onboarding | src/aws_ec2_auto_onboarding/AWSEc2AutoOnboarding.py | <reponame>nimrody15/cyberark-aws-auto-onboarding<gh_stars>0
import boto3
import json
import requests
import urllib3
import subprocess
import time
import random
from dynamo_lock import LockerClient
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
DEFAULT_HEADER = {"content-type": "application/json"... |
ichirod-japan/waganolib | tests/test_functions.py | <gh_stars>1-10
from wagano import calculation
def test_haversine():
assert calculation.haversine(52.370216, 4.895168, 52.520008,
13.404954) == 945793.4375088713 |
ichirod-japan/waganolib | setup.py | from setuptools import setup, find_packages
VERSION = '0.5.2'
DESCRIPTION = 'A package with japanese-related functions'
with open(r"D:\sys\downloads\Python Projects\waganolib\README.md", 'r') as f:
LONG_DESCRIPTION = f.read()
setup(
name="wagano",
version=VERSION,
author="<NAME... |
STMicroelectronics/meta-predmnt | recipes-predmnt/predmnt/utils/fs_utils.py | <gh_stars>1-10
#!/usr/bin/env python
################################################################################
# COPYRIGHT(c) 2022 STMicroelectronics #
# #
# Redistribution and use in source... |
STMicroelectronics/meta-predmnt | recipes-predmnt/predmnt/utils/aws_utils.py | #!/usr/bin/env python
################################################################################
# COPYRIGHT(c) 2022 STMicroelectronics #
# #
# Redistribution and use in source and binary for... |
STMicroelectronics/meta-predmnt | recipes-predmnt/predmnt/gui/main_pmp_gui.py | <reponame>STMicroelectronics/meta-predmnt
#!/usr/bin/env python3
################################################################################
# COPYRIGHT(c) 2022 STMicroelectronics #
# #
# Redi... |
STMicroelectronics/meta-predmnt | recipes-predmnt/predmnt/utils/definitions.py | <filename>recipes-predmnt/predmnt/utils/definitions.py
#!/usr/bin/env python
################################################################################
# COPYRIGHT(c) 2022 STMicroelectronics #
# ... |
STMicroelectronics/meta-predmnt | recipes-predmnt/predmnt/pmp.py | <filename>recipes-predmnt/predmnt/pmp.py
#!/usr/bin/env python
################################################################################
# COPYRIGHT(c) 2022 STMicroelectronics #
# #
# Redist... |
STMicroelectronics/meta-predmnt | recipes-predmnt/predmnt/utils/gtk_utils.py | <reponame>STMicroelectronics/meta-predmnt
#!/usr/bin/env python
################################################################################
# COPYRIGHT(c) 2022 STMicroelectronics #
# #
# Redistribu... |
STMicroelectronics/meta-predmnt | recipes-predmnt/predmnt/gui/run_pmp_gui.py | <reponame>STMicroelectronics/meta-predmnt
#!/usr/bin/env python
################################################################################
# COPYRIGHT(c) 2022 STMicroelectronics #
# #
# Redistribu... |
STMicroelectronics/meta-predmnt | recipes-predmnt/predmnt/gui/setup_pmp_gui.py | <filename>recipes-predmnt/predmnt/gui/setup_pmp_gui.py
#!/usr/bin/env python3
################################################################################
# COPYRIGHT(c) 2022 STMicroelectronics #
# ... |
STMicroelectronics/meta-predmnt | recipes-predmnt/predmnt/gui/setup_gw_gui.py | <reponame>STMicroelectronics/meta-predmnt
#!/usr/bin/env python3
################################################################################
# COPYRIGHT(c) 2022 STMicroelectronics #
# #
# Redi... |
TaikiAkita/mbstack-nodejs | scripts/ecg/generate.py | <filename>scripts/ecg/generate.py
#!/usr/bin/env python3
#
# Copyright 2019 - 2021 XiaoJSoft Studio. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE.md file.
#
import os
import sys
from typing import List, Union, Tuple
def convert_camelcase_to_d... |
fjt7tdmi/grass-photo | upload-photo.py | <filename>upload-photo.py
# Copyright 2018 <NAME>
#
# 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 a... |
fjt7tdmi/grass-photo | make-photo.py | <reponame>fjt7tdmi/grass-photo
# Copyright 2018 <NAME>
#
# 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... |
grittang/MySite | blog/forms.py | from django import forms
from .models import Post
class PostForm(forms.ModelForm):
"""Form for the image model"""
class Meta:
model = Post
fields = ('title', 'body', 'excerpt', 'avatar', 'category', 'tags', 'author')
|
grittang/MySite | blog/views.py | from django.http import HttpResponse
from django.shortcuts import render, get_object_or_404
from django.utils.html import strip_tags
from django.utils.text import slugify
from django.views.generic import ListView, DetailView
from pure_pagination.mixins import PaginationMixin
from .models import Post, Category, Tag
from... |
grittang/MySite | blog/templatetags/blog_extras.py | from django import template
from django.db.models.aggregates import Count
from ..models import Post, Category, Tag
import random
register = template.Library()
@register.inclusion_tag('blog/inclusions/_recent_posts.html', takes_context=True)
def show_recent_posts(context, num=5):
return {
'recent_post_lis... |
kai-subramanian/NLP-sentiment-analysis | bert_sentiment.py | from transformers import pipeline
import tweepy as tw
import praw
import streamlit as st
import pandas as pd
import os
import matplotlib.pyplot as plt
import seaborn as sns
import random
import requests
#import pandas_datareader as pdr
from pandas import json_normalize
from alpha_vantage.timeseries import TimeSeries
#... |
yoda7833/waifu-bot | bot.py | import io
import draw
import typing
import asyncio
import aiohttp
from functions import *
from discord.ext import commands
from fuzzywuzzy import process
from datetime import datetime
bot = commands.Bot(command_prefix="!", case_insensitive=True, help_command=None)
def get_command_help(command):
help = f"`{bot.com... |
ashok-arjun/continuum | tests/test_CUB200.py | import os
import pytest
from torchvision.transforms import Resize, ToTensor
from continuum.datasets import CUB200
from continuum.scenarios import ClassIncremental
DATA_PATH = os.environ.get("CONTINUUM_DATA_PATH")
'''
Test the visualization with instance_class scenario
'''
@pytest.mark.slow
def test_scenario_CUB200_... |
ashok-arjun/continuum | continuum/__init__.py | """Continuum lib.
Made by <NAME> and <NAME>.
The goal of this library is to provide clean and simple to use utilities for
Continual Learning.
"""
# pylint: disable=C0401
# flake8: noqa
from continuum import datasets
from continuum.scenarios import *
from continuum.tasks import *
from continuum.metrics import *
from c... |
ashok-arjun/continuum | continuum/datasets/cub200.py | <reponame>ashok-arjun/continuum
import os
from typing import Tuple
import pandas as pd
import numpy as np
from continuum.datasets.base import _ContinuumDataset
class CUB200(_ContinuumDataset):
# initial code taken from https://github.com/TDeVries/cub2011_dataset
base_folder = 'CUB_200_2011/images'
def ... |
ashok-arjun/continuum | continuum/datasets/base.py | import abc
from typing import List, Tuple, Union
import warnings
import numpy as np
from torchvision import datasets as torchdata
from torchvision import transforms
from continuum.transforms.segmentation import ToTensor as ToTensorSegmentation
class _ContinuumDataset(abc.ABC):
def __init__(self, data_path: str... |
ashok-arjun/continuum | continuum/scenarios/scenario_utils.py | import numpy as np
from continuum.datasets import InMemoryDataset
from continuum.scenarios import ContinualScenario
def create_subscenario(base_scenario, task_indexes):
"""
In this function we want to create a subscenario from the different tasks, either by subsampling tasks or reodering
or both.
"""
... |
ashok-arjun/continuum | generate_txt/gen.py | from continuum.datasets import CTRLplus |
ashok-arjun/continuum | continuum/tasks/task_set.py | from copy import copy
from typing import Tuple, Union, Optional
import numpy as np
import torch
from PIL import Image
from torch.utils.data import Dataset as TorchDataset
from torchvision import transforms
from continuum.viz import plot_samples
class TaskSet(TorchDataset):
"""A task dataset returned by the CLLo... |
ashok-arjun/continuum | tests/test_subscenarios.py | <reponame>ashok-arjun/continuum
import numpy as np
import pytest
import random
import string
from continuum.datasets import InMemoryDataset
from continuum.scenarios import ClassIncremental, ContinualScenario, create_subscenario
def gen_data():
x_train = np.random.randint(0, 255, size=(20, 32, 32, 3))
y_train... |
ashok-arjun/continuum | continuum/datasets/ctrl.py | from typing import List, Tuple, Union
from PIL import Image
from skimage.transform import resize
import numpy as np
from continuum.datasets import CIFAR10, SVHN, FashionMNIST, MNIST, DTD, RainbowMNIST
from continuum.datasets import _ContinuumDataset
class CTRL(_ContinuumDataset):
"""CTRL generic class.
Ref... |
ashok-arjun/continuum | continuum/datasets/core50.py | import os
from typing import Iterable, Set, Tuple, Union
import numpy as np
from continuum import download
from continuum.datasets.base import _ContinuumDataset
class Core50(_ContinuumDataset):
"""Continuum version of the Core50 dataset.
References:
* Core50: a new Dataset and Benchmark for Continu... |
ashok-arjun/continuum | continuum/download.py | <reponame>ashok-arjun/continuum
import os
import zipfile
import tarfile
from six.moves import urllib
# Fix error when downloading dataset from torchvision
# https://github.com/pytorch/vision/issues/1938#issuecomment-790730080
opener = urllib.request.build_opener()
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
u... |
madstk1/leon | packages/trend/github.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
import requests
import utils
import packages.trend.github_lang as github_lang
from re import search, escape
from bs4 import BeautifulSoup
def run(string, entities):
"""Grab the GitHub trends"""
# Number of repositories
limit = 5
# Range string
since = 'daily'
# T... |
madstk1/leon | packages/leon/partnerassistant.py | <filename>packages/leon/partnerassistant.py
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import utils
def run(string, entities):
"""Leon tells you about other personal assistants"""
string = string.lower()
assistants = [
'alexa',
'cortana',
'siri',
'google assistant'
]
for assistant in assistants:
i... |
madstk1/leon | packages/leon/greeting.py | <filename>packages/leon/greeting.py
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import utils
from datetime import datetime
from random import randint
def run(string, entities):
"""Leon greets you"""
time = datetime.time(datetime.now())
# 1/2 chance to get deeper greetings
if randint(0, 1) != 0:
if time.hour ... |
madstk1/leon | packages/hass/hass.py | <filename>packages/hass/hass.py
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import json
import utils
from requests import Request, Session
def power_on(string, entities):
"""Power on device, via Home Assistant"""
valid_err = handle_validity(string, entities)
if not valid_err == None:
return vali... |
madstk1/leon | bridges/python/utils.py | <filename>bridges/python/utils.py<gh_stars>1000+
#!/usr/bin/env python
# -*- coding:utf-8 -*-
from json import loads, dumps
from os import path, environ
from pathlib import Path
from random import choice
from sys import argv, stdout
from vars import useragent
from tinydb import TinyDB, Query, operations
from time impo... |
madstk1/leon | packages/network/speedtest.py | <reponame>madstk1/leon
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# The SpeedTest package will give you information about your network speed
# Author: <NAME>
# Date: 2019-03-09
# Based on the package https://github.com/sivel/speedtest-cli
import utils
import os
import sys
import subprocess
import re
def run(string... |
madstk1/leon | packages/checker/haveibeenpwned.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
import utils
from time import sleep
from urllib import parse
from requests import codes, exceptions
# Developer token
apikey = utils.config('api_key')
def run(string, entities):
"""Verify if one or several email addresses have been pwned"""
emails = []
... |
BlackDragonF/AlfredWorkflows | Meme/src/meme.py | #!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import sys
import json
import requests
import uuid
import shutil
# extract template_name and sentences from inputs
inputs = '{query}'.split(None, 1)
template_name = inputs[0]
sentences = inputs[1].split('|')
# generate api
api = 'https://sorry.xuty.tk/api/' + templ... |
BlackDragonF/AlfredWorkflows | Meme/src/filter.py | <reponame>BlackDragonF/AlfredWorkflows<filename>Meme/src/filter.py<gh_stars>1-10
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import json
# hard-coded available templates and information
templates = {
'sorry' : {
'placeholder' : ['好啊', '就算你是一流工程师', '就算你出报告再完美', '我叫你改报告你就要改', '毕竟我是客户', '客户了不起啊', 's... |
BlackDragonF/AlfredWorkflows | Wireless/src/scan.py | #!/usr/bin/python
import os
import sys
from xml.etree.ElementTree import Element, SubElement, tostring
reload(sys)
sys.setdefaultencoding("utf-8")
#Call built-in airport command
cmd_results = os.popen("/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s").read().split("\n")
i... |
jp30101995/CareerFinder | Data/api.py | from flask import request, url_for
from flask_api import FlaskAPI, status, exceptions
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
from surprise import NMF
from surprise import KNNWithMeans
from surprise import accuracy
from surprise.model_selection import K... |
JohnStarich/safari-cookies-cli | safari_cookies.py | #!/usr/bin/env python3
from io import BytesIO
from struct import unpack
from time import strftime, gmtime, time
import argparse
import json
import os
import sys
def main():
parser = argparse.ArgumentParser()
parser.add_argument('-f', '--file-path',
type=lambda f: check_file(parser, f)... |
jordanjwfisher/BeatSaberSongListParser | BeatSaberSongPuller.py | <gh_stars>0
import numpy as np
import os
rootdir = "D:\Oculus\Software\hyperbolic-magnetism-beat-saber\Beat Saber_Data\CustomLevels"
def fileLines(file):
line_count = 0
for line in file:
if line != "\n":
line_count += 1
return(line_count)
def songPuller(file):
with open(file, 'rt'... |
jeffreyc/memebuilder | memebuilder/builder/views.py | <filename>memebuilder/builder/views.py<gh_stars>0
import glob
import os
from os import path
from django import http
from django import shortcuts
from django import template
from django.conf import settings
from PIL import Image
from PIL import ImageColor
from PIL import ImageDraw
from PIL import ImageFont
templates ... |
jeffreyc/memebuilder | memebuilder/builder/urls.py | <reponame>jeffreyc/memebuilder
from django.conf.urls import patterns, include, url
# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()
urlpatterns = patterns('builder.views',
# Examples:
# url(r'^$', 'memebuilder.views.home', name='home'),
# url(r'... |
jeffreyc/memebuilder | memebuilder/builder/tests.py | <reponame>jeffreyc/memebuilder
import os
from os import path
import dingus
from django import test
from django.conf import settings
from PIL import ImageColor
from . import views
class MultiValueDingus(dingus.Dingus):
"""A Dingus that supports returning different return values on subsequent
calls.
A Mu... |
Vauxoo/cookiecutter | tests/test_compat.py | <reponame>Vauxoo/cookiecutter
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
test_compat
------------
Tests for `cookiecutter.compat` module.
"""
import os
from cookiecutter.compat import which
def test_existing_command():
cmd = which('date')
assert cmd
assert os.path.exists(cmd)
assert os.acce... |
Vauxoo/cookiecutter | tests/test_cli.py | <gh_stars>0
import os
import pytest
from click.testing import CliRunner
from cookiecutter.cli import main
from cookiecutter import utils
runner = CliRunner()
@pytest.fixture
def remove_fake_project_dir(request):
"""
Remove the fake project directory created during the tests.
"""
def fin_remove_fake... |
Vauxoo/cookiecutter | tests/test_vcs.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
test_vcs
------------
Tests for `cookiecutter.vcs` module.
"""
import locale
import os
import pytest
import subprocess
from cookiecutter import exceptions, utils, vcs
from tests.skipif_markers import skipif_no_network
ENCODING = locale.getdefaultlocale()[1]
@skip... |
Vauxoo/cookiecutter | tests/test_vcs_prompt.py | <gh_stars>1-10
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
test_vcs_prompt
---------------
"""
import os
import pytest
from cookiecutter import utils, vcs
from tests.skipif_markers import skipif_no_network
@pytest.fixture(autouse=True)
def clean_cookiecutter_dirs(request):
if os.path.isdir('cookiecutter-... |
Vauxoo/cookiecutter | tests/test_cookiecutter_repo_arg.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
test_cookiecutter_repo_arg
--------------------------
Tests formerly known from a unittest residing in test_main.py named
TestCookiecutterRepoArg.test_cookiecutter_git
TestCookiecutterRepoArg.test_cookiecutter_mercurial
"""
from __future__ import unicode_literals
imp... |
Vauxoo/cookiecutter | cookiecutter/config.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
cookiecutter.config
-------------------
Global configuration handling
"""
from __future__ import unicode_literals
import copy
import logging
import os
import io
import yaml
from .exceptions import ConfigDoesNotExistException
from .exceptions import InvalidConfigura... |
jsxyhdy/myweather | weather/migrations/0002_auto_20150802_1415.py | <filename>weather/migrations/0002_auto_20150802_1415.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('weather', '0001_initial'),
]
operations = [
migrations.RenameField(
... |
jsxyhdy/myweather | weather/views.py | # -*-coding:utf-8-*-
from django.shortcuts import render
from django.http import HttpResponse, Http404
from weather.models import CityInfo, Forecast
from weather.api_config import query_by_areaid
import json
# Create your views here.
def list_city(request):
return render(request, 'main.html')
def query_by_city(... |
jsxyhdy/myweather | weather/models.py | <gh_stars>0
# -*-coding:utf-8-*-
from django.db import models
# Create your models here.
class CityInfo(models.Model):
areaid = models.CharField(max_length=10)
nameen = models.CharField(max_length=20)
namecn = models.CharField(max_length=20)
districten = models.CharField(max_length=20)
districtcn ... |
jsxyhdy/myweather | weather/tests.py | from django.test import TestCase
from weather.models import *
# Create your tests here.
class TestWeather(TestCase):
def setUp(self):
from weather.api_config import query_by_areaid
self.city = CityInfo(areaid='101010100',
nameen='beijing', namecn='北京',
... |
jsxyhdy/myweather | weather/api_config.py | <filename>weather/api_config.py<gh_stars>0
"""
Weather API configure
常规预报输出示例: 输出示例:
"c":{
"c1":"101010100",
"c2":"beijing",
"c3":" 北京 ",
"c4":"beijing",
"c5":" 北 京",
"c6":"beijing",
"c7":" 北京 ",
"c8":"china",
"c9":" 中 国",
"c10":"1",
"c11":"010",
"c12":"100000",
"c13":"116.391",
"c14":"39.904",
"c15":"33",
"c16":"AZ901... |
jsxyhdy/myweather | weather/migrations/0004_forecast.py | <filename>weather/migrations/0004_forecast.py<gh_stars>0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('weather', '0003_auto_20150802_1419'),
]
operations = [
migrations.C... |
jsxyhdy/myweather | weather/migrations/0007_auto_20150809_0102.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('weather', '0006_auto_20150809_0032'),
]
operations = [
migrations.RenameField(
model_name='forecast',
... |
jsxyhdy/myweather | weather/migrations/0006_auto_20150809_0032.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
from django.utils.timezone import utc
import datetime
class Migration(migrations.Migration):
dependencies = [
('weather', '0005_auto_20150807_1525'),
]
operations = [
migrations.AddF... |
jsxyhdy/myweather | weather/admin.py | from django.contrib import admin
from weather.models import *
# Register your models here.
admin.site.register(CityInfo)
admin.site.register(Forecast)
|
jsxyhdy/myweather | weather/migrations/0001_initial.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
]
operations = [
migrations.CreateModel(
name='CityInfo',
fields=[
('id', models.AutoField(ser... |
MariaMalycha/dw_matrix | python_code.py | <gh_stars>0
# This is only test
print('test')
|
jimboca/udi-poly-IFTTT-Maker | ifttt-maker.py | <reponame>jimboca/udi-poly-IFTTT-Maker
#!/usr/bin/env python
"""
This is a TP-Link Kasa NodeServer for Polyglot v2 written in Python3
by JimBo <EMAIL>
"""
import sys
from udi_interface import Interface,LOGGER
from nodes import Controller
def main():
if sys.version_info < (3, 6):
LOGGER.error("ERROR: Pytho... |
jimboca/udi-poly-IFTTT-Maker | nodes/Controller.py |
import logging,requests,markdown2,os
from udi_interface import Node,LOGGER,Custom,LOG_HANDLER
from node_funcs import get_valid_node_name
from nodes import Webhook,POST_STATUS
class Controller(Node):
def __init__(self, poly, primary, address, name):
super(Controller, self).__init__(poly, primary, address,... |
jimboca/udi-poly-IFTTT-Maker | nodes/__init__.py |
""" Node classes used by the IFTTT Webhooks Node Server. """
import udi_interface
POST_STATUS = {
"None": 0,
"Success": 1,
"Network Error": 2,
"Request Error": 3,
"Invalid Error": 4,
"Authentication Error": 5,
"Data Error": 6,
"Other Error": 10,
}
from .Base import Base
from .We... |
jimboca/udi-poly-IFTTT-Maker | nodes/Webhook.py | <gh_stars>0
#
# Webhook IFTTT Node
#
from udi_interface import LOGGER
from nodes import Base
class Webhook(Base):
def __init__(self, controller, primary, event):
# May have different id's in the future?
self.id = 'Webhook'
# For now we just call the Base super
super().__init__(con... |
jimboca/udi-poly-IFTTT-Maker | nodes/Base.py | #
# IFTTT Webhooks Base Node
#
#
from udi_interface import Node,LOGGER
from node_funcs import get_valid_node_address,get_valid_node_name
class Base(Node):
def __init__(self, controller, primary, event):
self.controller = controller
self.event = event
self.ready = False
if not 'node... |
pythonprobr/jrpv | quiz/base/forms.py | from django.forms import ModelForm
from quiz.base.models import Aluno
class AlunoForm(ModelForm):
class Meta:
model = Aluno
fields = ['nome', 'email'] |
pythonprobr/jrpv | quiz/base/admin.py | from django.contrib import admin
from quiz.base.models import Pergunta, Aluno, Resposta
@admin.register(Pergunta)
class PerguntaAdmin(admin.ModelAdmin):
list_display = ('id', 'enunciado', 'disponivel')
@admin.register(Aluno)
class AlunoAdmin(admin.ModelAdmin):
list_display = ('id', 'nome', 'email', 'criado... |
pythonprobr/jrpv | quiz/base/views.py | <filename>quiz/base/views.py<gh_stars>1-10
from django.db.models import Sum
from django.shortcuts import render, redirect
# Create your views here.
from django.utils.timezone import now
from quiz.base.forms import AlunoForm
from quiz.base.models import Pergunta, Aluno, Resposta
def home(requisicao):
if requisic... |
jsourabh1/6Days6Company | Microsoft/rotate_90.py |
def rotate(matrix):
#code here
for i in range(len(matrix)):
listt = list(reversed(matrix[i]))
for j in range(len(matrix[i])):
matrix[i][j] = listt[j]
# print(matrix)
for i in range(len(matrix)):
for j in range(i, len(matrix[i])):
matrix[i][j], matrix... |
jsourabh1/6Days6Company | Adobe/Winner_of_elections.py | <reponame>jsourabh1/6Days6Company<gh_stars>1-10
from collections import defaultdict
class Solution:
#Complete this function
#Function to return the name of candidate that received maximum votes.
def winner(self, arr, n):
# Your code here
# return the name of the winning candidate and the... |
jsourabh1/6Days6Company | Amazon/Serialize and Deserialize.py |
'''
class Node:
def __init__(self,val):
self.data = val
self.left = None
self.right = None
'''
#Function to serialize a tree and return a list containing nodes of tree.
def serialize(root, A):
#code here
# vals = []
def doit(node):
nonlocal A
if node:
... |
jsourabh1/6Days6Company | Adobe/Longest_arithmetic_subsequence.py | <filename>Adobe/Longest_arithmetic_subsequence.py
class Solution:
def lengthOfLongestAP(self, nums, n):
# code here
if len(nums) <= 2:
return len(nums)
n = len(nums)
dp = [{} for i in range(n)]
results = 0
for i in range(1, n):
for j in ran... |
jsourabh1/6Days6Company | Walmart/maximum_performance_of_team.py | from heapq import *
class Solution:
def maxPerformance(self, n: int, speed: List[int], efficiency: List[int], k: int) -> int:
heap = []
res = summ = 0
for e, s in sorted(zip(efficiency, speed), reverse=True):
heappush(heap, s)
summ += s
if len(heap... |
jsourabh1/6Days6Company | Amazon/count_ways_to_Nth_stairs.py | <filename>Amazon/count_ways_to_Nth_stairs.py<gh_stars>1-10
import sys
import io
import atexit
class Solution:
#Function to count number of ways to reach the nth stair
#when order does not matter.
# Returns no. of ways to
# reach sth stair
def countWays(self, s):
mod = 1000000007
... |
jsourabh1/6Days6Company | Adobe/Minimum_sum_parition.py |
class Solution:
def equalPartition(self, N, arr):
# code here
if sum(arr)%2!=0:
return False
want=sum(arr)//2
dp=[[0]*(want+1) for i in range(N+1)]
for i in range(N+1):
for j in range(w... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.