repo_name stringlengths 6 97 | path stringlengths 3 341 | text stringlengths 8 1.02M |
|---|---|---|
jovahe/Mask_RCNN_RS | my/shp2json.py | <reponame>jovahe/Mask_RCNN_RS
# -*- coding: utf-8 -*-
from osgeo import ogr
import gdal
import sys
import os
import fire
def ChangeToJson(vector, output):
print("Starting........")
#打开矢量图层
gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "YES")
gdal.SetConfigOption("SHAPE_ENCODING", "GBK")
shp_ds = og... |
jovahe/Mask_RCNN_RS | my/shp2COCO.py | <filename>my/shp2COCO.py<gh_stars>0
import os,sys
import numpy as np
import glob
import json
import PIL.Image
from shapely.geometry import Polygon
from osgeo import ogr, gdal
gdal.UseExceptions()
from labelme import utils # necessary
def get_file(file_dir, file_type=[".jpg",'.png', '.tif', '.tiff','.img','.pix']):... |
jovahe/Mask_RCNN_RS | my/shp2mask.py | # -*- coding: utf-8 -*-
from osgeo import gdal, ogr,osr
from osgeo.gdalconst import *
import numpy as np
import os
from os import path
import cv2
import matplotlib.pyplot as plt
gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8","NO")
gdal.AllRegister() #注册驱动
ogr.RegisterAll()
img_path="/home/omnisky/PycharmProjects/dat... |
jovahe/Mask_RCNN_RS | my/tools/geo_convert.py | """
将mask rcnn转成shapefile的一些函数
"""
from osgeo import ogr, gdal, osr
import cv2
import numpy as np
def create_geom():
"""用于测试,生成一个wkt"""
multipolygon = ogr.Geometry(ogr.wkbMultiPolygon)
polygon = ogr.Geometry(ogr.wkbPolygon)
ring = ogr.Geometry(ogr.wkbLinearRing)
ring.AddPoint(1179091.1646903288, ... |
Newlance/ha-nicehash | custom_components/nicehash/payout_sensors.py | """
NiceHash Rig Payout Sensors
"""
from datetime import datetime
import logging
from homeassistant.const import ATTR_ATTRIBUTION
from homeassistant.helpers.entity import Entity
from .const import (
CURRENCY_BTC,
DEFAULT_NAME,
FORMAT_DATETIME,
ICON_CURRENCY_BTC,
ICON_PULSE,
ICON_THERMOMETER,
... |
Newlance/ha-nicehash | custom_components/nicehash/switch.py | """
Sensor platform for NiceHash
"""
import logging
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_ATTRIBUTION
from homeassistant.core import Config, HomeAssistant
from .const import (
BALANCE_TYPE_AVAILABLE,
BALANCE_TYPE_PENDING,
BALANCE_TYPE_TOTAL,
CURRENCY... |
Newlance/ha-nicehash | custom_components/nicehash/control_switches.py | """
NiceHash Rig controls
"""
from datetime import datetime
import logging
from homeassistant.const import ATTR_ATTRIBUTION
from homeassistant.helpers.entity import Entity
from homeassistant.components.switch import SwitchEntity
from .coordinators import MiningRigsDataUpdateCoordinator
from .nicehash import MiningRig... |
Newlance/ha-nicehash | custom_components/nicehash/account_sensors.py | """
NiceHash Account Sensors
"""
import logging
from homeassistant.const import ATTR_ATTRIBUTION
from homeassistant.helpers.entity import Entity
from .const import (
BALANCE_TYPE_AVAILABLE,
BALANCE_TYPE_PENDING,
BALANCE_TYPE_TOTAL,
CURRENCY_BTC,
CURRENCY_EUR,
CURRENCY_USD,
DEFAULT_NAME,
... |
Newlance/ha-nicehash | custom_components/nicehash/coordinators.py | <filename>custom_components/nicehash/coordinators.py
"""
NiceHash Data Update Coordinators
"""
from datetime import timedelta
import logging
from homeassistant.core import HomeAssistant
from homeassistant.helpers.update_coordinator import (
DataUpdateCoordinator,
UpdateFailed,
)
from .const import (
CURRE... |
Newlance/ha-nicehash | custom_components/nicehash/device_sensors.py | """
NiceHash Rig Device Sensors
"""
from datetime import datetime
import logging
from homeassistant.const import ATTR_ATTRIBUTION
from homeassistant.helpers.entity import Entity
from .const import (
DEVICE_STATUS_UNKNOWN,
DEVICE_LOAD,
DEVICE_RPM,
DEVICE_SPEED_ALGORITHM,
DEVICE_SPEED_RATE,
ICON... |
Newlance/ha-nicehash | custom_components/nicehash/rig_sensors.py | <reponame>Newlance/ha-nicehash
"""
NiceHash Rig Sensors
"""
from datetime import datetime
import logging
from homeassistant.const import ATTR_ATTRIBUTION
from homeassistant.helpers.entity import Entity
from .const import (
CURRENCY_BTC,
DEVICE_STATUS_UNKNOWN,
FORMAT_DATETIME,
ICON_CURRENCY_BTC,
IC... |
JustasGau/DonjinKrawler | install-hooks.py | <reponame>JustasGau/DonjinKrawler
import sys
from os import path
import urllib; from urllib.request import urlretrieve
from subprocess import call
def install_hooks(directory):
checkstyleUrl = 'https://github.com/checkstyle/checkstyle/releases/download/checkstyle-8.36.1/checkstyle-8.36.1-all.jar'
preCommitUrl ... |
CarlosMart626/graphene-django-authorization | graphene_django_authorization/fields.py | from django.core.exceptions import PermissionDenied
from graphene_django.filter.fields import DjangoFilterConnectionField
from graphene_django.fields import DjangoConnectionField
from graphene_django import DjangoObjectType
from .utils import is_related_to_user, has_perm
class AuthDjangoFilterConnectionField(DjangoF... |
CarlosMart626/graphene-django-authorization | graphene_django_authorization/test/models.py | from django.db import models
class Pet(models.Model):
name = models.CharField(max_length=30)
|
CarlosMart626/graphene-django-authorization | setup.py | from setuptools import find_packages, setup
from graphene_django_authorization import __version__
tests_require = [
'pytest>=2.7.2',
'pytest-cov',
'coveralls',
'coverage==4.4.2',
'mock',
'pytz',
'django-filter',
'pytest-django==3.1.2',
'graphene-django<2.0',
'django<2.0'
]
se... |
CarlosMart626/graphene-django-authorization | examples/starwars/models.py | <gh_stars>1-10
from __future__ import absolute_import
from django.db import models
class Character(models.Model):
name = models.CharField(max_length=50)
ship = models.ForeignKey('Ship', blank=True, null=True, related_name='characters')
def __str__(self):
return self.name
class Faction(models.M... |
CarlosMart626/graphene-django-authorization | graphene_django_authorization/auth/fields.py | from django.core.exceptions import PermissionDenied
from graphene_django.filter.fields import DjangoFilterConnectionField
from graphene_django.fields import DjangoConnectionField
class AuthDjangoFilterConnectionField(DjangoFilterConnectionField):
_permission = ''
@classmethod
def has_perm(cls, context):
... |
CarlosMart626/graphene-django-authorization | graphene_django_authorization/tests/test_auth.py | <reponame>CarlosMart626/graphene-django-authorization
import collections
import graphene
import pytest
from graphene import Schema, relay, ObjectType
from django.test import TestCase, RequestFactory
from graphene_django import DjangoObjectType
from graphene_django_authorization.auth.mixins import AuthNodeMixin, AuthMut... |
CarlosMart626/graphene-django-authorization | graphene_django_authorization/auth/mixins.py | <reponame>CarlosMart626/graphene-django-authorization<filename>graphene_django_authorization/auth/mixins.py
from django.core.exceptions import PermissionDenied
class AuthNodeMixin():
_permission = ''
@classmethod
def get_node(cls, id, context, info):
def has_perm(object_instance):
if... |
CarlosMart626/graphene-django-authorization | graphene_django_authorization/decorators.py | from functools import wraps
from django.core.exceptions import PermissionDenied
from .utils import has_perm, is_unauthorized_to_mutate_object
def require_permission(permissions, model=None, id_field=None, user_field=None):
def require_permission_decorator(func):
@wraps(func)
def func_wrapper(cls,... |
CarlosMart626/graphene-django-authorization | examples/cookbook/cookbook/recipes/admin.py | from django.contrib import admin
from cookbook.recipes.models import Recipe, RecipeIngredient
class RecipeIngredientInline(admin.TabularInline):
model = RecipeIngredient
@admin.register(Recipe)
class RecipeAdmin(admin.ModelAdmin):
inlines = [RecipeIngredientInline]
|
CarlosMart626/graphene-django-authorization | graphene_django_authorization/utils.py | <filename>graphene_django_authorization/utils.py
""""
Auth utils module.
Define some functios to authorize user to user mutations or nodes.
"""
def is_related_to_user(object_instance, user, field):
"""Return True when the object_instance is related to user."""
user_instance = getattr(object_instance, field, ... |
CarlosMart626/graphene-django-authorization | examples/cookbook/cookbook/schema.py | import cookbook.ingredients.schema
import cookbook.recipes.schema
import graphene
from graphene_django.debug import DjangoDebug
class Query(cookbook.recipes.schema.Query, cookbook.ingredients.schema.Query, graphene.ObjectType):
debug = graphene.Field(DjangoDebug, name='__debug')
schema = graphene.Schema(query=... |
CarlosMart626/graphene-django-authorization | examples/starwars/tests/test_mutation.py | <gh_stars>1-10
import pytest
<<<<<<< HEAD
=======
from unittest.mock import Mock
>>>>>>> develop
from ..data import initialize
from ..schema import schema
pytestmark = pytest.mark.django_db
<<<<<<< HEAD
=======
class MockUserContext(object):
def __init__(self, authenticated=True, is_staff=False, superuser=Fals... |
CarlosMart626/graphene-django-authorization | examples/cookbook-plain/cookbook/recipes/models.py | from django.db import models
from cookbook.ingredients.models import Ingredient
class Recipe(models.Model):
title = models.CharField(max_length=100)
instructions = models.TextField()
class RecipeIngredient(models.Model):
recipe = models.ForeignKey(Recipe, related_name='amounts')
ingredient = models... |
bio-boris/kb_SPAdes | test/kb_SPAdes_server_test.py | <reponame>bio-boris/kb_SPAdes
from __future__ import print_function
import unittest
import os
import time
from os import environ
from ConfigParser import ConfigParser
import psutil
import requests
from biokbase.workspace.client import Workspace as workspaceService # @UnresolvedImport @IgnorePep8
from biokbase.worksp... |
bio-boris/kb_SPAdes | lib/kb_ea_utils/kb_ea_utilsClient.py | <filename>lib/kb_ea_utils/kb_ea_utilsClient.py
# -*- coding: utf-8 -*-
############################################################
#
# Autogenerated by the KBase type compiler -
# any changes made here will be overwritten
#
############################################################
from __future__ import print_func... |
infobloxopen/bloxone-ansible | ansible_collections/infoblox/b1ddi_modules/plugins/modules/b1_a_record_gather.py | #!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (c) 2021 Infoblox, Inc.
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
DOCUMENTATION = '''
---
module: b1_a_record_gather
author: ... |
oKermorgant/ecn_manip | src/python/dh_code.py | #!/usr/bin/env python
'''
C++ code generation for Modified Denavit-Hartenberg parameters and URDF files
python dh_code.py file.yml (from yaml file)
python dh_code.py file.urdf base effector (from URDF file)
author: <NAME>, ICube Laboratory
'''
import yaml
from lxml import etree
import sys, os
import sympy
from sy... |
PrimatElite/ml-labs | src/common/__init__.py | from .image import load_image
from .object import Object, PIXELS_PER_MM
from .object_search import find_object
from .objects_packing import pack_objects
|
PrimatElite/ml-labs | src/intelligent_placer.py | <filename>src/intelligent_placer.py
import numpy as np
from typing import Optional, Union
from .placer import placer
def check_image(image: Union[str, np.ndarray], polygon: Optional[np.ndarray] = None) -> bool:
return placer.run(image, polygon)
|
PrimatElite/ml-labs | src/common/objects_packing.py | import numpy as np
def pack_objects(polygon: np.ndarray, objects: np.ndarray) -> bool:
return True
|
PrimatElite/ml-labs | test.py | <reponame>PrimatElite/ml-labs<gh_stars>0
import argparse
import time
from src.checker.tester import Tester
def register_launch_arguments():
parser = argparse.ArgumentParser(description='Serve the connector application')
parser.add_argument('-o', '--objects', help='path to the directory with objects images', ... |
PrimatElite/ml-labs | src/common/object.py | <gh_stars>0
import cv2
import numpy as np
from shapely.geometry import Polygon
from typing import Tuple, Union
from .image import load_image
from .object_search import find_object, PAPER_SIZE
PIXELS_PER_MM = PAPER_SIZE[0] / 297
class Object:
image: np.ndarray
convex_hull: np.ndarray
scaled_convex_hull... |
PrimatElite/ml-labs | src/common/image.py | import cv2
import numpy as np
from typing import Union
def load_image(image_or_path: Union[str, np.ndarray]) -> np.ndarray:
if isinstance(image_or_path, str):
image = cv2.imread(image_or_path, cv2.IMREAD_COLOR)
if image is None:
raise FileNotFoundError(image_or_path)
elif isinstan... |
PrimatElite/ml-labs | src/__init__.py | from . import intelligent_placer
|
PrimatElite/ml-labs | setup.py | <reponame>PrimatElite/ml-labs
from setuptools import setup
setup(
name='intelligent_placer_lib',
version='0.0.1',
packages=['intelligent_placer_lib', 'intelligent_placer_lib.common', 'intelligent_placer_lib.placer'],
package_dir={'intelligent_placer_lib': 'src'},
install_requires=['numpy', 'opencv-... |
PrimatElite/ml-labs | src/placer/polygon_search.py | <gh_stars>0
import numpy as np
def find_polygon(image: np.ndarray) -> np.ndarray:
return np.array([])
|
PrimatElite/ml-labs | src/checker/tester.py | <gh_stars>0
from __future__ import annotations
import cv2
import matplotlib.pyplot as plt
import numpy as np
import os
import pandas as pd
import plotly.express as px
import time
from functools import reduce
from imutils import rotate_bound
from intelligent_placer_lib import intelligent_placer
from itertools import i... |
PrimatElite/ml-labs | src/utils/test_util.py | <filename>src/utils/test_util.py<gh_stars>0
import json
import os
import pytest
from . import load_config, validate_config
@pytest.fixture(scope="function")
def resource_setup():
print("\n Init")
examples_path = "./config_examples"
examples = next(os.walk(examples_path), (None, None, []))[2]
return ... |
PrimatElite/ml-labs | src/placer/solver.py | import numpy as np
from typing import List, Optional, Union
from .objects_search import find_objects
from .polygon_search import find_polygon
from ..common import load_image, Object, pack_objects
class Solver:
objects: List[Object]
def __init__(self):
self.objects = []
def run(self, image: Uni... |
PrimatElite/ml-labs | src/placer/__init__.py | from .solver import Solver
placer = Solver()
|
PrimatElite/ml-labs | src/utils/__init__.py | import json
import jsonschema
import yaml
def load_config(path: str) -> dict:
with open(path, 'r') as stream:
document = yaml.safe_load(stream)
return document
def validate_config(obj: dict):
scheme_path = './restrictions_schema.json'
with open(scheme_path, 'r') as file:
schema = jso... |
PrimatElite/ml-labs | src/placer/objects_search.py | <filename>src/placer/objects_search.py
import numpy as np
from typing import List
from ..common import Object
def find_objects(image: np.ndarray, objects: List[Object]) -> np.ndarray:
return np.array([obj.convex_hull for obj in objects])
|
PrimatElite/ml-labs | src/common/object_search.py | import cv2
import numpy as np
from imutils import perspective, rotate_bound
from pymatting import estimate_alpha_knn, estimate_foreground_ml, stack_images
from typing import Tuple
PAPER_SIZE = (1485, 1050)
def find_paper(image_bgr: np.ndarray) -> np.ndarray:
image_hsv = cv2.cvtColor(image_bgr, cv2.COLOR_BGR2HS... |
mthpower/django-force-logout | setup.py | from setuptools import setup, find_packages
setup(
name='django-force-logout',
url="https://chris-lamb.co.uk/projects/django-force-logout",
version='3.2.0',
description="Framework to be able to forcibly log users out of Django projects",
author="<NAME>",
author_email='<EMAIL>',
license="B... |
mthpower/django-force-logout | django_force_logout/middleware.py | import time
import django
import datetime
from django.contrib import auth
from django.utils.module_loading import import_string
from . import app_settings
if django.VERSION > (1, 10):
from django.utils.deprecation import MiddlewareMixin
def is_authenticated(user):
return user.is_authenticated
else:... |
tadeoj/bazel_gwt_2.8.2 | bazel/gwt_application.bzl | def _gwt_war_impl(ctx):
output_war = ctx.outputs.output_war
output_dir = output_war.path + ".gwt_output"
lib_dir = output_dir + "/" + "WEB-INF/lib"
extra_dir = output_war.path + ".extra"
# Find all transitive dependencies
all_deps = _get_dep_jars(ctx)
# Run the GWT compiler
cmd = "%s %... |
tadeoj/bazel_gwt_2.8.2 | bazel/gwt_2_8_2_deps.bzl | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_jar")
load("@bazel_tools//tools/build_defs/repo:jvm.bzl", "jvm_maven_import_external")
def generated_maven_jars(
omit_commons_io_commons_io = False,
omit_org_apache_commons_commons_io = False,
omit_com_google_code_findbugs_jsr305 = Fals... |
inyutin/aiopg | tests/test_sa_cursor.py | import pytest
import sqlalchemy as sa
meta = sa.MetaData()
tbl = sa.Table(
'sa_tbl5', meta,
sa.Column('ID', sa.String, primary_key=True, key='id'),
sa.Column('Name', sa.String(255), key='name'),
)
@pytest.fixture
def connect(make_sa_connection, loop):
async def start():
conn = await make_sa_c... |
inyutin/aiopg | aiopg/transaction.py | import enum
import uuid
import warnings
from abc import ABC
import psycopg2
from aiopg.utils import _TransactionPointContextManager
__all__ = ('IsolationLevel', 'Transaction')
class IsolationCompiler(ABC):
__slots__ = ('_isolation_level', '_readonly', '_deferrable')
def __init__(self, isolation_level, rea... |
DeanDupalov/my_project | grocery_store/grocery_store/cart/views.py | <filename>grocery_store/grocery_store/cart/views.py
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.contrib.auth.mixins import LoginRequiredMixin
from django.core.exceptions import ObjectDoesNotExist
from django.shortcuts import get_object_or_404, redirect, rend... |
DeanDupalov/my_project | grocery_store/grocery_store/product/models.py | from django.core.validators import MinValueValidator
from django.db import models
class Category(models.Model):
BAKERY = 'Bakery'
FRUITS = 'Fruits'
VEGETABLES = 'Vegetables'
MEAT = 'Meat'
RICE_AND_PASTA = 'Rice and Pasta'
FISH_AND_SEAFOOD = 'Fish and Seafood'
OILS_VINEGAR_AND_DRIED_HERBS =... |
DeanDupalov/my_project | grocery_store/core/image_file_testing.py | from io import BytesIO
from PIL import Image
from django.core.files import File
def get_image_file(name='test.png', ext='png', size=(50, 50), color=(256, 0, 0)):
file_obj = BytesIO()
image = Image.new("RGB", size=size, color=color)
image.save(file_obj, ext)
file_obj.seek(0)
return File(file_obj, ... |
DeanDupalov/my_project | grocery_store/grocery_store/store/forms.py | from django import forms
from core.mixins.bootstrap_form import BootstrapFormMixin
class ContactForm(forms.Form, BootstrapFormMixin):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.setup_form()
first_name = forms.CharField(max_length=50, required=True)
last_n... |
DeanDupalov/my_project | grocery_store/tests/store/views/test_index_view.py |
from django.test import TestCase, Client
from django.urls import reverse
from core.image_file_testing import get_image_file
from grocery_store.product.models import Product, Category, DiscountProduct
class IndexViewTests(TestCase):
def setUp(self):
self.test_client = Client()
def test_IndexView_wh... |
DeanDupalov/my_project | grocery_store/grocery_store/product/migrations/0001_initial.py | # Generated by Django 3.2.5 on 2021-07-31 12:12
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Category... |
DeanDupalov/my_project | grocery_store/tests/profiles/views/test_edit_profile.py | <reponame>DeanDupalov/my_project
from django.test import TestCase, Client
from django.urls import reverse
from grocery_store.grocery_auth.models import GroceryUser
from grocery_store.profiles.models import Profile
class EditProfileView(TestCase):
def setUp(self):
self.test_client = Client()
self.... |
DeanDupalov/my_project | grocery_store/grocery_store/store/urls.py | <reponame>DeanDupalov/my_project
from django.urls import path
from grocery_store.store.views import IndexView, ListAllProductsView, list_category_products, contact_view
urlpatterns = [
path('', IndexView.as_view(), name='landing page'),
path('list/', ListAllProductsView.as_view(), name='list products'),
p... |
DeanDupalov/my_project | grocery_store/tests/cart/views/test_add_to_cart.py | from django.test import TestCase, Client
from django.urls import reverse
from core.image_file_testing import get_image_file
from grocery_store.cart.models import Order, OrderItem
from grocery_store.grocery_auth.models import GroceryUser
from grocery_store.product.models import Category
from grocery_store.profiles.mode... |
DeanDupalov/my_project | grocery_store/tests/grocery_test_utils.py | from grocery_store.cart.models import Order
from grocery_store.grocery_auth.models import GroceryUser
from grocery_store.product.models import Product
from grocery_store.profiles.models import Profile
class GroceryTestUtils:
def create_profile(self, **kwargs):
return Profile.objects.create()
def cr... |
DeanDupalov/my_project | grocery_store/grocery_store/product/admin.py | from django.contrib import admin
from grocery_store.product.models import Category, Product, DiscountProduct
@admin.register(Category)
class CategoryAdmin(admin.ModelAdmin):
pass
@admin.register(Product)
class ProductAdmin(admin.ModelAdmin):
pass
@admin.register(DiscountProduct)
class DiscountProductAdmi... |
DeanDupalov/my_project | grocery_store/tests/store/views/test_contac_view.py | from django.test import TestCase, Client
from django.urls import reverse
from grocery_store.grocery_auth.models import GroceryUser
class ContactViewTests(TestCase):
def setUp(self):
self.test_client = Client()
self.user = GroceryUser.objects.create_user(
email='<EMAIL>',
... |
DeanDupalov/my_project | grocery_store/grocery_store/product/validators.py | from django.core.exceptions import ValidationError
def validate_max_value(max_value):
def internal_validate(value):
if value >= max_value:
raise ValidationError(f'{value} is greater or equal to the {max_value}')
return internal_validate
|
DeanDupalov/my_project | grocery_store/grocery_store/product/views.py | from django.contrib.auth.decorators import login_required
from django.contrib.auth.mixins import LoginRequiredMixin
from django.shortcuts import render, redirect
from django.urls import reverse_lazy
from django.views.generic import CreateView
from grocery_store.product.forms import ProductCreateForm, DiscountProductFo... |
DeanDupalov/my_project | grocery_store/grocery_store/grocery_auth/models.py | <reponame>DeanDupalov/my_project<gh_stars>0
from django.contrib.auth.base_user import AbstractBaseUser
from django.contrib.auth.models import PermissionsMixin, User
from django.db import models
from grocery_store.grocery_auth.manager import GroceryUserManager
class GroceryUser(AbstractBaseUser, PermissionsMixin):
... |
DeanDupalov/my_project | grocery_store/grocery_store/settings.py |
from pathlib import Path
from os.path import join
# Build paths inside the project like this: BASE_DIR / 'subdir'.
from django.urls import reverse_lazy
BASE_DIR = Path(__file__).resolve().parent.parent
SECRET_KEY = '<KEY>'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOS... |
DeanDupalov/my_project | grocery_store/grocery_store/product/urls.py | <reponame>DeanDupalov/my_project<filename>grocery_store/grocery_store/product/urls.py<gh_stars>0
from django.urls import path
from grocery_store.product.views import AddProduct, product_details, edit_product, delete_products, AddDiscountProduct
urlpatterns = [
path('add/', AddProduct.as_view(), name='add product')... |
DeanDupalov/my_project | grocery_store/grocery_store/cart/models.py | from django.db import models
from grocery_store.product.models import Product
from grocery_store.profiles.models import Profile
class OrderItem(models.Model):
user = models.ForeignKey(
Profile,
on_delete=models.CASCADE,
)
ordered = models.BooleanField(default=False)
item = models.Forei... |
DeanDupalov/my_project | grocery_store/grocery_store/profiles/views.py | from django.contrib.auth.decorators import login_required
from django.contrib.auth.views import PasswordChangeView
from django.db import transaction
from django.shortcuts import render, redirect
from grocery_store.grocery_auth.forms import EditUserForm
from grocery_store.profiles.forms import ProfileForm, ProfileAddres... |
DeanDupalov/my_project | grocery_store/tests/profiles/views/test_profile_details.py | <gh_stars>0
from django.test import TestCase, Client
from django.urls import reverse
from grocery_store.grocery_auth.models import GroceryUser
class ProfileDetailsView(TestCase):
def setUp(self):
self.test_client = Client()
self.user = GroceryUser.objects.create_user(
email='<EMAIL>',... |
DeanDupalov/my_project | grocery_store/grocery_store/cart/urls.py | from django.urls import path
from grocery_store.cart.views import add_to_cart, delete_one_from_cart, OrderSummaryView, delete_from_cart, CheckoutView
urlpatterns = [
path('order_detail/', OrderSummaryView.as_view(), name='order details'),
path('checkout/', CheckoutView.as_view(), name='checkout'),
path('a... |
DeanDupalov/my_project | grocery_store/tests/cart/views/test_order_summary_view.py | from django.test import TestCase, Client
from django.urls import reverse
from core.image_file_testing import get_image_file
from grocery_store.cart.models import Order, OrderItem
from grocery_store.grocery_auth.models import GroceryUser
from grocery_store.product.models import Category
from grocery_store.profiles.mode... |
DeanDupalov/my_project | grocery_store/grocery_store/grocery_auth/apps.py | <filename>grocery_store/grocery_store/grocery_auth/apps.py
from django.apps import AppConfig
class GroceryAuthConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'grocery_store.grocery_auth'
|
DeanDupalov/my_project | grocery_store/grocery_store/store/views.py | from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.core.mail import send_mail, BadHeaderError
from django.http import HttpResponse
from django.shortcuts import render, redirect
from django.views.generic import TemplateView, ListView
from grocery_store.product.mode... |
DeanDupalov/my_project | grocery_store/grocery_store/profiles/forms.py | <reponame>DeanDupalov/my_project<gh_stars>0
from django import forms
from core.mixins.bootstrap_form import BootstrapFormMixin
from grocery_store.profiles.models import Profile, ProfileAddress
class ProfileForm(forms.ModelForm, BootstrapFormMixin):
def __init__(self, *args, **kwargs):
super().__init__(*a... |
DeanDupalov/my_project | grocery_store/grocery_store/cart/admin.py | from django.contrib import admin
# Register your models here.
from grocery_store.cart.models import OrderItem, Order
admin.site.register(OrderItem)
admin.site.register(Order) |
DeanDupalov/my_project | grocery_store/grocery_store/product/forms.py | <filename>grocery_store/grocery_store/product/forms.py
from django import forms
from django.core.exceptions import ValidationError
from core.mixins.bootstrap_form import BootstrapFormMixin
from grocery_store.product.models import Product, DiscountProduct
class ProductCreateForm(forms.ModelForm, BootstrapFormMixin):
... |
DeanDupalov/my_project | grocery_store/tests/product/views/test_product_details.py | <reponame>DeanDupalov/my_project
from django.test import TestCase, Client
from django.urls import reverse
from core.image_file_testing import get_image_file
from grocery_store.product.models import Product, Category
class ProductDetailsView(TestCase):
def setUp(self):
self.test_client = Client()
def... |
DeanDupalov/my_project | grocery_store/grocery_store/profiles/admin.py | from django.contrib import admin
from grocery_store.profiles.models import Profile, ProfileAddress
admin.site.register(Profile)
admin.site.register(ProfileAddress) |
DeanDupalov/my_project | grocery_store/tests/product/views/test_edit_product.py | <gh_stars>0
from django.test import TestCase, Client
from django.urls import reverse
from core.image_file_testing import get_image_file
from grocery_store.grocery_auth.models import GroceryUser
from grocery_store.product.models import Product, Category
class EditProductViewTest(TestCase):
def setUp(self):
... |
DeanDupalov/my_project | grocery_store/grocery_store/profiles/models.py | from django.contrib.auth import get_user_model
from django.core.validators import MinValueValidator
from django.db import models
from grocery_store.product.models import Product
UserModel = get_user_model()
class Profile(models.Model):
first_name = models.CharField(
max_length=30,
)
surname = mo... |
DeanDupalov/my_project | grocery_store/grocery_store/grocery_auth/forms.py | from django import forms
from django.contrib.auth import authenticate, get_user_model
from django.contrib.auth.forms import UserCreationForm, UserChangeForm
from core.mixins.bootstrap_form import BootstrapFormMixin
UserModel = get_user_model()
class SignUpForm(UserCreationForm, BootstrapFormMixin):
def __init__... |
DeanDupalov/my_project | grocery_store/grocery_store/cart/forms.py | <reponame>DeanDupalov/my_project
from django import forms
from core.mixins.bootstrap_form import BootstrapFormMixin
class CheckoutForm(forms.Form, BootstrapFormMixin):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.setup_form()
shipping_address = forms.CharField(... |
DeanDupalov/my_project | grocery_store/grocery_store/cart/migrations/0002_initial.py | <gh_stars>0
# Generated by Django 3.2.5 on 2021-07-31 12:12
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('cart', '0001_initial'),
('profiles', '0001_initial'),
]
operations = [
... |
DeanDupalov/my_project | grocery_store/grocery_store/profiles/migrations/0001_initial.py | # Generated by Django 3.2.5 on 2021-07-31 12:12
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('product', '0001_initial'),
('grocery_auth', '0001_initial'),
]... |
DeanDupalov/my_project | grocery_store/grocery_store/grocery_auth/views.py | from django.contrib.auth import login, logout
from django.contrib.auth.decorators import login_required
from django.db import transaction
from django.shortcuts import render, redirect
from django.views.generic import TemplateView
from grocery_store.grocery_auth.forms import SignInForm, SignUpForm
from grocery_store.p... |
DeanDupalov/my_project | grocery_store/grocery_store/grocery_auth/urls.py | from django.urls import path
from grocery_store.grocery_auth.views import sign_in, sign_out, RegisterView
urlpatterns = [
path('sign-up/', RegisterView.as_view(), name='sign up'),
path('sign-in/', sign_in, name='sign in'),
path('sign-out/', sign_out, name='sign out'),
] |
DeanDupalov/my_project | grocery_store/tests/store/views/test_list_all_products_view.py | from django.test import TestCase, Client
from django.urls import reverse
from core.image_file_testing import get_image_file
from grocery_store.product.models import Product, Category
class ListAllProductsViewTest(TestCase):
def setUp(self):
self.test_client = Client()
def test_ListAllProductsView_wh... |
DeanDupalov/my_project | grocery_store/grocery_store/urls.py | <filename>grocery_store/grocery_store/urls.py
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('auth/', include('grocery_store.grocery_auth.urls')),
path('... |
DeanDupalov/my_project | grocery_store/grocery_store/profiles/urls.py | <reponame>DeanDupalov/my_project
from django.urls import path
from grocery_store.profiles.views import edit_profile, profile_details, ChangePasswordView
urlpatterns = [
path('profile_details/', profile_details, name='profile details'),
path('edit_profile/', edit_profile, name='edit profile'),
path('change... |
kevingessner/python | kubernetes/client/models/v1beta1_rule_with_operations.py | # coding: utf-8
"""
Kubernetes
No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
OpenAPI spec version: v1.9.3
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
from pprint import pformat
from six import iteritems
import re
... |
windowdong11/mit-ocw-pdf-downloader | main.py | <gh_stars>0
"""
input Example
https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-042j-mathematics-for-computer-science-spring-2015/lecture-slides/
"""
import requests
from bs4 import BeautifulSoup
import os.path
import re
print("Target URL should be start with 'https://ocw.mit.edu'.")
print("Ex... |
exoji2e/Hashcode-2021-qual-practice-20210218 | solvers/solve_example.py | import argparse
import random
from collections import *
from dataparser import parse
# inp is an input file as a single string
# return your output as a string
def solve(inp, args):
# TODO: Solve the problem
random.seed(args['seed'])
ns = parse(inp)
return '''2
2 1 4
3 0 2 3'''
|
exoji2e/Hashcode-2021-qual-practice-20210218 | score.py | from dataparser import *
from collections import *
# inp: the input file as a single string
# out: the answer file produced by your solver, as a single string
# return the score of the output as an integer
def score(inp, out):
ns = parse(inp)
itr = (line for line in out.split('\n'))
D = ni(itr)
assert ... |
exoji2e/Hashcode-2021-qual-practice-20210218 | sum_score.py | #!/user/bin/env pypy3
import glob
from util import path, score2str
try:
import json
j = json.loads(open('max.json', 'r').read())
except:
j = {}
S = 0
for name in sorted(j.keys()):
v = j[name]['score']
f = j[name]['folder']
pys = glob.glob('{}/*.py'.format(f))
sol_name = ''
if pys:
... |
exoji2e/Hashcode-2021-qual-practice-20210218 | solvers/solve.py | <reponame>exoji2e/Hashcode-2021-qual-practice-20210218<gh_stars>0
import argparse
import random
from collections import *
from dataparser import parse
# inp is an input file as a single string
# return your output as a string
def solve(inp, args):
# TODO: Solve the problem
random.seed(args['seed'])
ns = pa... |
bclau/trening | testing/gigi.py | print "Buna! Sung gigi! Sunt petrolier! <NAME>'!"
print "Gigi este momentan conflictuat despre ce sa faca..."
print "Azi sunt mai vorbaret decat deobicei! N-am ce face, se termina sesiunea..."
|
timoschick/form-context-model | fcm/my_log.py | <gh_stars>10-100
import logging
names = set()
def __setup_custom_logger(name: str) -> logging.Logger:
formatter = logging.Formatter(fmt='%(asctime)s - %(levelname)s - %(module)s - %(message)s')
names.add(name)
handler = logging.StreamHandler()
handler.setFormatter(formatter)
logger = logging.g... |
timoschick/form-context-model | fcm/test/test_ngram_builder.py | <reponame>timoschick/form-context-model
import os
import unittest
import numpy as np
import numpy.testing as npt
import my_log
from ngram_builder import NGramBuilder, UNK_TOKEN
logger = my_log.get_logger('root')
class TestNGramBuilder(unittest.TestCase):
def test_ngram_builder(self):
vocab_file = os.pat... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.