repo_name
stringlengths
6
97
path
stringlengths
3
341
text
stringlengths
8
1.02M
sscherfke/jinja2-time
tests/test_now.py
<filename>tests/test_now.py # -*- coding: utf-8 -*- import pendulum import pytest from jinja2 import Environment, exceptions @pytest.fixture def environment(): return Environment(extensions=['jinja2_time.TimeExtension']) @pytest.yield_fixture(autouse=True) def freeze(monkeypatch): monkeypatch.setattr( ...
TunedMystic/url-shortener
main/links/models.py
import random import re from django.conf import settings from django.db import models from django.db.models import Sum from django.utils import timezone class Link(models.Model): ''' Basic Link. ''' created_on = models.DateTimeField(auto_now_add=True) modified_on = models.DateTimeField(default=t...
TunedMystic/url-shortener
main/links/decorators.py
<reponame>TunedMystic/url-shortener<gh_stars>0 from functools import wraps from django.core.exceptions import PermissionDenied def link_owner(wrapped_function): ''' A decorator to allow the owner of the Link to proceed. ''' @wraps(wrapped_function) def wrapper(request, *args, **kwargs): k...
TunedMystic/url-shortener
main/config/production.py
from config.settings import * DEBUG = False ALLOWED_HOSTS = ['*']
TunedMystic/url-shortener
main/links/forms.py
from urllib.parse import urlparse from django import forms from django.conf import settings from django.contrib.sites.models import Site from .models import Link, Tag class LinkFormMixin(object): def __init__(self, *args, **kwargs): self.user = kwargs.pop('user', None) super(LinkFormMixin, self)...
TunedMystic/url-shortener
main/links/admin.py
from django.contrib import admin from .models import Link, Tag class LinkAdmin(admin.ModelAdmin): readonly_fields = ('unique_addresses',) def unique_addresses(self, instance): unique_ips = instance.addresses.count() if unique_ips >= 50: return '{} Unique IP Addresses'.format(uni...
TunedMystic/url-shortener
main/links/utils.py
from django.contrib.gis.geoip2 import GeoIP2 from django.contrib.sites.models import Site from django.db.models import F from django.utils import timezone import geoip2 from analytics.models import Country, Referer, Region def update_link_unique_ips(link, ip_address=None): ''' Update Unique IP addresses for...
TunedMystic/url-shortener
main/links/migrations/0001_initial.py
<reponame>TunedMystic/url-shortener # -*- coding: utf-8 -*- # Generated by Django 1.10.2 on 2016-10-29 05:37 from __future__ import unicode_literals from django.conf import settings from django.db import migrations, models import django.db.models.deletion import django.utils.timezone class Migration(migrations.Migra...
TunedMystic/url-shortener
main/users/models.py
<reponame>TunedMystic/url-shortener from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin from django.db import models from django.utils import timezone from django.utils.translation import ugettext_lazy as _ from .managers import CustomUserManager class User(AbstractBaseUser, PermissionsMixin): ...
TunedMystic/url-shortener
main/config/gunicorn.py
<gh_stars>0 import os BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) raw_env = 'DJANGO_SETTINGS_MODULE=config.production' HOST = '0.0.0.0' PORT = '8000' bind = '{}:{}'.format(HOST, PORT) accesslog = '/app/log/gunicorn-access.log' errorlog = '/app/log/gunicorn-error.log' workers = 1 relo...
TunedMystic/url-shortener
scripts/make_ssl.py
#!/usr/bin/env python # Generate an ssl certificate and key. # 1) Create a private server key. # 2) Create a certificate signing request. # 3) Remove the passphrase. # 4) Sign the SSL certificate. # 5) Remove copied files. import os import optparse parser = optparse.OptionParser() parser.add_option( "-o", "--out...
TunedMystic/url-shortener
main/links/urls.py
<reponame>TunedMystic/url-shortener from django.conf.urls import url from . import views urlpatterns = [ url( r'^$', views.index, name='index' ), url( r'^dashboard/$', views.dashboard, name='dashboard' ), url( r'^shorten/$', views.sho...
TunedMystic/url-shortener
main/users/forms.py
from django import forms from django.contrib.auth.forms import (ReadOnlyPasswordHashField) from django.utils.translation import ugettext_lazy as _ from .models import User class UserCreationForm(forms.ModelForm): ''' A form for creating new users in the Admin, with no privileges, from the given email and...
TunedMystic/url-shortener
main/users/views.py
<gh_stars>0 from django.contrib.auth import login from django.shortcuts import render, redirect from .forms import SignupForm def signup(request): ''' Signup for a new User account. ''' form = SignupForm(request.POST or None) if request.method == 'POST': if form.is_valid(): ...
TunedMystic/url-shortener
main/links/migrations/0004_generate_default_titles_for_titleless_links.py
# -*- coding: utf-8 -*- # Generated by Django 1.10.2 on 2016-11-15 20:02 from __future__ import unicode_literals from django.db import migrations class Migration(migrations.Migration): def generate_titles(apps, schema_editor): Links = apps.get_model('links', 'Link') # Get all links that don't ha...
TunedMystic/url-shortener
scripts/db.py
<filename>scripts/db.py #!/usr/bin/env python from argparse import ArgumentParser import os from os.path import abspath, dirname, join import sys DB_NAME = join(dirname(dirname(abspath(__file__))), 'db.sqlite3') DUMP = 'sqlite3 {} .dump > {}' RESTORE = 'sqlite3 {} < {}' def write(s): sys.stdout.write(s) if __n...
TunedMystic/url-shortener
main/links/tests/test_views.py
from django.test import TestCase from django.contrib.sites.models import Site from django.core.urlresolvers import reverse from users.models import User from links.models import Link, Tag class LinkTests(TestCase): fixtures = ['users', 'links'] site_domain = 'testexample.com' def setUp(self): ''...
TunedMystic/url-shortener
main/links/tests/test_utils.py
from django.test import TestCase from links.models import Link, Tag class TagUtilsTest(TestCase): def test_one_whitespace_string(self): ''' Test normalize_text method with one whitespace. ''' text = Tag.normalize_text(' ') self.assertEqual(text, '') def test_...
TunedMystic/url-shortener
main/config/utils.py
import collections import datetime import json from os.path import join from django.conf import settings def dump_request(request): request_data = serialize_request(request.META) filename = 'request-{}.json'.format( datetime.datetime.now().strftime('%s') ) path = join(settings.ROOT_DIR, sett...
TunedMystic/url-shortener
main/analytics/migrations/0002_referer_model.py
# -*- coding: utf-8 -*- # Generated by Django 1.10.2 on 2016-11-26 03:43 from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion import django.utils.timezone class Migration(migrations.Migration): initial = True dependencies = [ ('analytics'...
TunedMystic/url-shortener
main/analytics/admin.py
<reponame>TunedMystic/url-shortener from django.contrib import admin from .models import Country, Region, Referer # Register your models here. admin.site.register(Country) admin.site.register(Region) admin.site.register(Referer)
TunedMystic/url-shortener
main/config/urls.py
<filename>main/config/urls.py """main URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.10/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url(r'^$', views....
TunedMystic/url-shortener
main/links/views.py
<reponame>TunedMystic/url-shortener<filename>main/links/views.py from django.conf import settings from django.contrib.auth.decorators import login_required from django.contrib.sites.models import Site from django.http import JsonResponse, HttpResponse from django.shortcuts import render, redirect, reverse, get_object_o...
TunedMystic/url-shortener
main/links/tests/test_forms.py
from django.test import TestCase from django.contrib.sites.models import Site from users.models import User from links.forms import LinkForm, LinkEditForm from links.models import Link, Tag class LinkTests(TestCase): fixtures = ['users', 'links'] site_domain = 'testexample.com' def setUp(self): ...
TunedMystic/url-shortener
main/links/tests/test_pages.py
from django.test import TestCase from django.contrib.sites.models import Site from django.core.urlresolvers import reverse from users.models import User class LinkTests(TestCase): fixtures = ['users', 'links'] site_domain = 'testexample.com' def setUp(self): ''' Modify the current site w...
TunedMystic/url-shortener
main/links/migrations/0002_auto_20161106_0137.py
<filename>main/links/migrations/0002_auto_20161106_0137.py # -*- coding: utf-8 -*- # Generated by Django 1.10.2 on 2016-11-06 01:37 from __future__ import unicode_literals from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('links', '0001_initial'), ] opera...
TunedMystic/url-shortener
main/links/migrations/0005_auto_20161115_2208.py
# -*- coding: utf-8 -*- # Generated by Django 1.10.2 on 2016-11-15 22:08 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('links', '0004_generate_default_titles_for_titleless_links'), ] operations = [ ...
TunedMystic/url-shortener
scripts/django_shell.py
<reponame>TunedMystic/url-shortener import os from os.path import abspath, dirname, join import sys import django def print_header(): header = """ _ _ _ _ _ __| | (_) __ _ _ __ __ _ ___ ___ | |__ ___ | || | / _` | | | / _` || '_ \ / _` | ...
TunedMystic/url-shortener
main/users/managers.py
<reponame>TunedMystic/url-shortener<filename>main/users/managers.py from django.contrib.auth.models import BaseUserManager from django.utils import timezone class CustomUserManager(BaseUserManager): def _create_user(self, email, password, is_staff, is_superuser, **extra_fields): if not email: ...
TunedMystic/url-shortener
main/analytics/migrations/0003_country_region.py
# -*- coding: utf-8 -*- # Generated by Django 1.10.2 on 2016-11-26 20:52 from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion import django.utils.timezone class Migration(migrations.Migration): dependencies = [ ('links', '0005_auto_20161115_22...
TunedMystic/url-shortener
main/analytics/models.py
from urllib.parse import urlparse from django.db import models from django.utils import timezone from links.models import Link class IPAddress(models.Model): ''' The IPAddress model will hold ip address information for a link. Collectively, all IPAddress relations for a Link will be unique. ''' ...
TunedMystic/url-shortener
main/config/management/commands/download_geolite.py
<gh_stars>0 import gzip import os import shutil import urllib from django.conf import settings from django.core.management.base import BaseCommand class Command(BaseCommand): help = 'Download the geolite binaries and store in GEOIP_PATH' def download_and_extract_file(self, item): filename = item.get...
marlin97/DS-Unit-3-Sprint-1-Software-Engineering
Sprint-Challenge/acme_report.py
#! /usr/bin/env python3 from random import randint, sample, uniform from acme import Product ADJECTIVES = ['Awesome', 'Shiny', 'Impressive', 'Portable', 'Improved'] NOUNS = ['Anvil', 'Catapult', 'Disguise', 'Mousetrap', '???'] def generate_products(num_products=30): """ Randomly generate a given ...
marlin97/DS-Unit-3-Sprint-1-Software-Engineering
Sprint-Challenge/acme.py
<reponame>marlin97/DS-Unit-3-Sprint-1-Software-Engineering<filename>Sprint-Challenge/acme.py #! /usr/bin/env python3 import random class Product: """ The acme product class, holds the data for every product they sell """ def __init__(self, name, price=10, weight=20, flammability=0.5): ...
marlin97/DS-Unit-3-Sprint-1-Software-Engineering
Sprint-Challenge/acme_test.py
#! /usr/bin/env python3 import unittest from acme import Product from acme_report import generate_products, ADJECTIVES, NOUNS class AcmeProductTests(unittest.TestCase): """Making sure Acme products are the tops!""" def test_default_product_price(self): """Test default product price being ...
bxprdr25/python-api-challenge
WeatherPy/keys.py
<filename>WeatherPy/keys.py # OpenWeatherMap API Key weather_api_key = "577868ccc6e6a642a594460b395be979" # Google API Key g_key = "<KEY>"
minatuyang/start-with-rasp-pi
hog_v.py
import logging import os import warnings import datetime import imutils import time from imutils.object_detection import non_max_suppression from imutils import paths import numpy as np import cv2 warnings.filterwarnings("ignore") def hog_video(): cap = cv2.VideoCapture("vtest.avi") hog = cv2.HOGDescriptor(...
minatuyang/start-with-rasp-pi
hog_p.py
<reponame>minatuyang/start-with-rasp-pi import logging import os import warnings import datetime import imutils import time from imutils.object_detection import non_max_suppression from imutils import paths import numpy as np import cv2 warnings.filterwarnings("ignore") def hog_picture(): img=cv2.imread('123.JPG...
minatuyang/start-with-rasp-pi
acc_v.py
<reponame>minatuyang/start-with-rasp-pi from init.iot10086 import Iot10086 import logging import os import warnings import datetime import imutils import time import cv2 import socket import numpy def acc_video(): warnings.filterwarnings("ignore") ## print datetime.datetime.now() ## print "socket load...
minatuyang/start-with-rasp-pi
facepp_v.py
<filename>facepp_v.py import logging import os import warnings import datetime import imutils import time from imutils.object_detection import non_max_suppression from imutils import paths import numpy as np import cv2 import urllib2 import urllib import json import jsonpath from init.facepp import FacePP def facepp_...
minatuyang/start-with-rasp-pi
facepp_p.py
# -*- coding: utf-8 -*- import urllib2 import urllib import time import json import jsonpath import cv2 import datetime from init.facepp import FacePP def facepp_picture(): print datetime.datetime.now() http_url='https://api-cn.faceplusplus.com/humanbodypp/v1/detect' key = "<KEY>" secret = ...
minatuyang/start-with-rasp-pi
main.py
<reponame>minatuyang/start-with-rasp-pi<gh_stars>0 # -*- coding: utf-8 -*- from facepp_v import facepp_video from facepp_p import facepp_picture from hog_v import hog_video from hog_p import hog_picture from acc_v import acc_video print 'please enter the model' print '1 for ACCweight' print '2 for HOG' print...
thifujikawa/clientes_olist
Query/geracao_abt.py
<reponame>thifujikawa/clientes_olist<gh_stars>0 ########################################################################################################## ################# Projeto para detecção de vendedores que podem deixar da base da Olist. ################# ########### Etapa 2/5 ETL Extraction Transform Load - Gera...
thifujikawa/clientes_olist
Modelling/get_last_model.py
<reponame>thifujikawa/clientes_olist ########################################################################################################## ################# Projeto para detecção de vendedores que podem deixar da base da Olist. ################# ###################################### Etapa 4/5 Operacionalização ##...
MiguelAndres03/acortadorcpe-urls
urlshort/admin.py
<gh_stars>1-10 from django.contrib import admin from .models import ShortURL # Register your models here. admin.site.register(ShortURL)
MiguelAndres03/acortadorcpe-urls
urlshort/urls.py
<filename>urlshort/urls.py from django.urls import path from .views import home, createShortURL, sendto, consultURL, registerUser, logoutRequest, loginRequest from django.contrib.auth.decorators import login_required app_name = 'urlshort' urlpatterns = [ path('', login_required(home), name='home'), path('<str...
MiguelAndres03/acortadorcpe-urls
urlshort/apps.py
from django.apps import AppConfig class UrlshortConfig(AppConfig): name = 'urlshort'
MiguelAndres03/acortadorcpe-urls
urlshort/forms.py
from .models import ShortURL from django.contrib.auth.models import User from django import forms class CreateNewShortURL(forms.ModelForm): class Meta: model=ShortURL fields = {'original_url', 'description','short_url'} widgets = { 'original_url': forms.TextInput(attrs={'class'...
MiguelAndres03/acortadorcpe-urls
urlshort/models.py
from django.db import models # Create your models here. class ShortURL(models.Model): original_url = models.URLField(max_length=700) short_url = models.CharField(max_length=100) description = models.CharField(max_length=500) time_date_created = models.DateTimeField() def __str__(self): re...
MiguelAndres03/acortadorcpe-urls
urlshort/views.py
from django.shortcuts import render, redirect from django.contrib.auth.forms import UserCreationForm, AuthenticationForm from django.contrib.auth import login, logout, authenticate from django.http import HttpResponseRedirect from django.contrib import messages from .models import ShortURL from .forms import CreateNewS...
alexkuz/sublime-scalafmt
Scalafmt.py
<gh_stars>0 import os import sublime import sublime_plugin import subprocess import sys import time class ScalafmtFormatFileCommand(sublime_plugin.TextCommand): def run(self, edit): full_path = self.view.file_name() _, file_extension = os.path.splitext(full_path) if file_extension == '.sca...
JanezRadescek/HearthStone
baza.py
#!/usr/bin/python # -*- encoding: utf-8 -*- from bottle import * import auth import csv import psycopg2, psycopg2.extensions, psycopg2.extras psycopg2.extensions.register_type(psycopg2.extensions.UNICODE) # se znebimo problemov s sumniki ###################################################################### # pri...
JanezRadescek/HearthStone
spletna aplikacija.py
<gh_stars>0 #!/usr/bin/python # -*- encoding: utf-8 -*- # uvozimo bottle.py from bottle import * # uvozimo ustrezne podatke za povezavo import auth_public as auth # uvozimo psycopg2 from psycopg2 import IntegrityError import psycopg2, psycopg2.extensions, psycopg2.extras psycopg2.extensions.register_type(psycopg2.ex...
musicalmacdonald/firstpitime
test.py
<reponame>musicalmacdonald/firstpitime #counting to ten on pi ''' for i in range(1,11): print(i) ''' i=1 while i<=10: print(i) i+=1
jfuechsl/simplesvc
simplesvc/volumes/__init__.py
<gh_stars>0 def get_mounts(): try: with open('/proc/mounts', 'r') as f: mounts = [line.split()[1] for line in f.readlines()] return mounts except: return []
jfuechsl/simplesvc
simplesvc/__init__.py
<filename>simplesvc/__init__.py from flask import Flask, render_template from .volumes import get_mounts from .envvars import get_environment_variables from .xkcd import get_current_xkcd app = Flask(__name__) @app.route('/') def root_route(): mounts = get_mounts() env_vars = get_environment_variables('EY_') xk...
jfuechsl/simplesvc
simplesvc/xkcd/__init__.py
<reponame>jfuechsl/simplesvc import requests def _unsuccessful_result(): return { 'success': False } def _successful_result(result): return { 'success': True, 'data': result } def get_current_xkcd(): try: r = requests.get('https://xkcd.com/info.0.json', timeout=5) if r.status_code...
jfuechsl/simplesvc
simplesvc/envvars/__init__.py
import os def get_environment_variables(starting_with): return [[env_name, env_value] for env_name, env_value in os.environ.items() if env_name.startswith(starting_with)]
iamjackwachira/wwfh
apps/jobs/migrations/0007_auto_20201028_2200.py
# Generated by Django 3.1.2 on 2020-10-28 22:00 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('jobs', '0006_auto_20201028_1232'), ] operations = [ migrations.AddField( model_name='jobpost', name='regional_restri...
iamjackwachira/wwfh
apps/jobs/middleware/general.py
from collections import namedtuple from django.conf import settings from jobs.choices import JOB_CATEGORY_CHOICES, JOB_TYPE_CHOICES class SharedContextMiddleware: """ Middleware class that injects common data that's needed when rendering most of view responses into the context of the template_respons...
iamjackwachira/wwfh
apps/jobs/forms.py
from django import forms from tinymce.widgets import TinyMCE import jobs.choices as choices from .models import Company, JobPost class TinyMCEWidget(TinyMCE): def use_required_attribute(self, *args): return False class JobPostForm(forms.Form): job_title = forms.CharField() job_application_url ...
iamjackwachira/wwfh
config/gunicorn_conf.py
workers = 2 timeout = 120 reload = True limit_request_field_size = 0 limit_request_line = 0
iamjackwachira/wwfh
apps/jobs/migrations/0003_auto_20201028_1035.py
# Generated by Django 3.1.2 on 2020-10-28 10:35 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('jobs', '0002_auto_20201028_1034'), ] operations = [ migrations.AlterField( model_name='company', name='logo', ...
iamjackwachira/wwfh
apps/jobs/migrations/0004_auto_20201028_1104.py
# Generated by Django 3.1.2 on 2020-10-28 11:04 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('jobs', '0003_auto_20201028_1035'), ] operations = [ migrations.RenameField( model_name='jobpost', old_name='regional_restric...
iamjackwachira/wwfh
apps/jobs/migrations/0005_auto_20201028_1217.py
<reponame>iamjackwachira/wwfh<gh_stars>0 # Generated by Django 3.1.2 on 2020-10-28 12:17 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('jobs', '0004_auto_20201028_1104'), ] operations = [ migrations.RenameField( model_name='jobpost...
iamjackwachira/wwfh
apps/jobs/urls.py
<gh_stars>0 from django.urls import path from . import views app_name = "jobs" urlpatterns = [ path("", views.JobListView.as_view(), name="jobs-home"), path("jobs/new/", views.JobCreateView.as_view(), name="job-create"), path("jobs/<int:pk>/", views.JobDetailView.as_view(), name="job-detail"), path( ...
iamjackwachira/wwfh
apps/jobs/migrations/0001_initial.py
# Generated by Django 3.1.2 on 2020-10-25 17:30 from django.db import migrations, models import django.db.models.deletion import tinymce.models class Migration(migrations.Migration): initial = True dependencies = [ ] operations = [ migrations.CreateModel( name='Category', ...
iamjackwachira/wwfh
apps/jobs/admin.py
<reponame>iamjackwachira/wwfh<filename>apps/jobs/admin.py from django.contrib import admin from .models import JobPost, Company class JobPostAdmin(admin.ModelAdmin): list_display = ("title", "job_type", "job_category", "company") display = "Job Post" class CompanyAdmin(admin.ModelAdmin): list_display =...
iamjackwachira/wwfh
config/settings/local.py
<reponame>iamjackwachira/wwfh from .base import * # noqa import dj_database_url DATABASES = { "default": dj_database_url.parse(env("DATABASE_URL")) }
iamjackwachira/wwfh
apps/core/models.py
<gh_stars>0 from django.db import models class BaseModel(models.Model): """ An abstract base class model that provides self updating ``created_on`` and ``modified_on`` fields. """ created_on = models.DateTimeField(auto_now_add=True, editable=False) modified_on = models.DateTimeField(auto_now=...
iamjackwachira/wwfh
apps/jobs/views.py
from collections import defaultdict from django.db.models import Count from django.shortcuts import redirect, render from django.urls import reverse from django.views.generic import DetailView, ListView, FormView from .choices import ( JOB_TYPE_CHOICES, JOB_CATEGORY_CHOICES, REGIONAL_RESTRICTIONS_CHOICES,...
iamjackwachira/wwfh
apps/jobs/tests.py
import datetime from django.test import TestCase from django.urls import reverse from django.utils import timezone from jobs.models import Company, JobPost from jobs.choices import JOB_CATEGORY_CHOICES, JOB_TYPE_CHOICES, REGIONAL_RESTRICTIONS_CHOICES from jobs.forms import JobPostForm def create_job(title, category...
iamjackwachira/wwfh
config/settings/test.py
""" Test specific settings. """ from .base import * DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'testdb', } }
iamjackwachira/wwfh
apps/jobs/choices.py
<gh_stars>0 from model_utils import Choices from django.utils.translation import ugettext_lazy as _ JOB_TYPE_CHOICES = Choices( ("full_time", _("Full Time")), ("contract", _("Contract")), ) JOB_CATEGORY_CHOICES = Choices( ("design", _("Design")), ("programming", _("Programming")), ("customer_supp...
iamjackwachira/wwfh
apps/jobs/migrations/0009_auto_20201102_1651.py
# Generated by Django 3.1.2 on 2020-11-02 16:51 from django.db import migrations import jobs.models class Migration(migrations.Migration): dependencies = [ ('jobs', '0008_company_headquarters'), ] operations = [ migrations.AlterField( model_name='company', name='...
iamjackwachira/wwfh
apps/jobs/models.py
<gh_stars>0 from django.db import models from cloudinary.models import CloudinaryField as BaseCloudinaryField from core.models import BaseModel from tinymce.models import HTMLField import jobs.choices as choices class CloudinaryField(BaseCloudinaryField): def upload_options(self, model_instance): return ...
nitely/regexy
regexy/shared/collections/__init__.py
# -*- coding: utf-8 -*- from .states_set import StatesSet __all__ = ['StatesSet']
nitely/regexy
regexy/compile/nfa.py
<filename>regexy/compile/nfa.py # -*- coding: utf-8 -*- """ Tools for creating the NFA states :private: """ import copy from typing import ( Iterator, Tuple) from ..shared.nodes import ( Node, EOF, CharNode, RepetitionRangeNode, OpNode, SkipNode, AssertionNode) from ..shared impo...
nitely/regexy
regexy/shared/nodes.py
<reponame>nitely/regexy # -*- coding: utf-8 -*- """ This module contains all\ the node types of the NFA :ivar Node EOF: EOFNode singleton :private: """ import unicodedata from typing import ( Sequence, Callable, Iterator, Tuple) __all__ = [ 'Node', 'CharNode', 'SymbolNode', 'OpNode',...
nitely/regexy
regexy/__init__.py
<filename>regexy/__init__.py<gh_stars>10-100 # -*- coding: utf-8 -*- """ Public API """ from .compile import to_nfa as compile from .process import match, full_match, search from .shared import exceptions __all__ = [ 'compile', 'match', 'full_match', 'search', 'exceptions'] __version__ = '0.17'...
nitely/regexy
regexy/compile/__init__.py
# -*- coding: utf-8 -*- from . import compile __doc__ = compile.__doc__ __all__ = [ 'to_nfa', 'to_rpn', 'to_atoms'] to_nfa = compile.to_nfa to_rpn = compile.to_rpn to_atoms = compile.to_atoms
nitely/regexy
tests/tests.py
<reponame>nitely/regexy<filename>tests/tests.py # -*- coding: utf-8 -*- import unittest import logging import regexy from regexy.compile import to_atoms logging.disable(logging.CRITICAL) def new_full_match(expression, text): return regexy.full_match( regexy.compile(expression), text) def full_match(...
nitely/regexy
regexy/compile/compile.py
<reponame>nitely/regexy<gh_stars>10-100 # -*- coding: utf-8 -*- """ Tools for compiling a regular expression\ into some of the in-between conversions\ from infix regular expression to NFA The compiling steps are not made for\ performance but for readability and maintainability.\ This is mostly because resulting NFAs ...
nitely/regexy
regexy/shared/exceptions.py
# -*- coding: utf-8 -*- """ This module contains all the\ exceptions this library may raise """ __all__ = [ 'RegexyError', 'MatchError'] class RegexyError(Exception): """ Base exception for all custom\ errors raised by this library :public: """ class MatchError(RegexyError): """ ...
nitely/regexy
regexy/compile/rpn.py
# -*- coding: utf-8 -*- """ Tools for converting an infix regular\ expression into a suffix regex (RPN) This is based on Shunting-yard algorithm,\ but modified to support regex primitives\ such as groups :private: """ import collections from typing import ( Iterator, List) from ..shared.nodes import ( ...
nitely/regexy
regexy/compile/parse.py
# -*- coding: utf-8 -*- """ Tools to parse a regular expression into nodes :private: """ from typing import ( Iterator, List, Tuple) from ..shared import nodes from ..shared import Symbols __all__ = [ 'parse', 'fill_groups', 'join_atoms'] SYMBOLS = { Symbols.JOINER: nodes.OpNode, ...
nitely/regexy
regexy/process/__init__.py
# -*- coding: utf-8 -*- """ This module contains all the tools of regex matching """ from .match import match, full_match, search __all__ = [ 'match', 'full_match', 'search']
nitely/regexy
regexy/shared/symbols.py
# -*- coding: utf-8 -*- """ This module contains all the regex\ symbols such as operators and capturing groups """ class Symbols: """ Symbols that a regex and/or a NFA may contain :ivar str JOINER: for juxtaposition of regex atoms :ivar str ZERO_OR_ONE: ``?`` matches zero or one char/group :ivar...
nitely/regexy
regexy/process/captures.py
<reponame>nitely/regexy # -*- coding: utf-8 -*- """ Tools for creating the capturing\ groups matching results of ``match``\ and friends :private: """ import collections from typing import ( Union, Tuple, Optional) from ..shared import Symbols __all__ = [ 'Capture', 'capture', 'matched'] ...
nitely/regexy
regexy/process/match.py
<reponame>nitely/regexy<filename>regexy/process/match.py<gh_stars>10-100 # -*- coding: utf-8 -*- """ Matching for regular expressions :private: """ from typing import ( List, Tuple, Iterator, Union, Set) from ..shared.nodes import ( EOF, CharNode, GroupNode, Node, AssertionNo...
nitely/regexy
regexy/shared/__init__.py
# -*- coding: utf-8 -*- """ Internally shared resources """ from .symbols import Symbols from . import nodes from . import exceptions __all__ = [ 'Symbols', 'nodes', 'exceptions']
nitely/regexy
regexy/shared/collections/states_set.py
# -*- coding: utf-8 -*- __all__ = ['StatesSet'] class StatesSet: STATE, CAPTURED = range(2) def __init__(self): self._list = [] self._set = set() def __len__(self): return len(self._list) def __bool__(self): return bool(self._list) def __iter__(self): ...
GeekMasher/markdown-to-projects
markdowntoprojects/models.py
from typing import List from dataclasses import dataclass, field def loader(klass, dikt): try: fieldtypes = klass.__annotations__ return klass(**{f: loader(fieldtypes[f], dikt[f]) for f in dikt}) except KeyError as err: raise Exception(f"Unknown key being set in configuration file : {...
GeekMasher/markdown-to-projects
markdowntoprojects/__main__.py
import os import time import yaml import logging import argparse from typing import List from dataclasses import dataclass from requests import session as requests_session from markdowntoprojects.models import * # read project directory from file # connect to github api to create a new project from a markdown file ...
joanRVAllen/flask_example
flask_example/example_app.py
'''example of 1 file flask application that uses an API and ORM''' import requests from flask import Flask from flask_sqlalchemy import SQLAlchemy # TODO make API request # configuratinos for application app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite3' app.config['SQLALCHEMY_TRACK...
intel-spark/automl
pyzoo/zoo/automl/regression/time_sequence_predictor.py
# # Copyright 2018 Analytics Zoo Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to...
intel-spark/automl
pyzoo/test/zoo/automl/model/test_VanillaLSTM.py
<reponame>intel-spark/automl<filename>pyzoo/test/zoo/automl/model/test_VanillaLSTM.py<gh_stars>0 # # Copyright 2018 Analytics Zoo Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # ...
intel-spark/automl
pyzoo/zoo/automl/model/VanillaLSTM.py
<filename>pyzoo/zoo/automl/model/VanillaLSTM.py # # Copyright 2018 Analytics Zoo Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # ...
intel-spark/automl
pyzoo/test/zoo/automl/regression/test_time_sequence_predictor.py
<filename>pyzoo/test/zoo/automl/regression/test_time_sequence_predictor.py # # Copyright 2018 Analytics Zoo Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache....
intel-spark/automl
pyzoo/zoo/automl/common/util.py
# # Copyright 2018 Analytics Zoo Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to...