genui.utils package

Subpackages

Submodules

genui.utils.admin module

genui.utils.apps module

class genui.utils.apps.UtilsConfig(app_name, app_module)[source]

Bases: AppConfig

name = 'genui.utils'

genui.utils.exceptions module

exceptions

Created by: Martin Sicho On: 7/23/20, 10:08 AM

exception genui.utils.exceptions.GenUIException(original, *args, **kwargs)[source]

Bases: GenUIExceptionMixIn, Exception

class genui.utils.exceptions.GenUIExceptionMixIn(original, *args, **kwargs)[source]

Bases: object

asJSON()[source]
getData()[source]
exception genui.utils.exceptions.GenUIWarning(original, *args, **kwargs)[source]

Bases: GenUIExceptionMixIn, Warning

genui.utils.genuisetup module

genuisetup

Created by: Martin Sicho On: 4/28/20, 4:33 PM

genui.utils.genuisetup.setup(*args, **kwargs)[source]

genui.utils.gpu module

gpu

Created by: Martin Sicho On: 6/2/20, 9:11 AM

exception genui.utils.gpu.GPUAllocationException(device, *args)[source]

Bases: Exception

genui.utils.gpu.allocate(strict=False)[source]
genui.utils.gpu.check_availability()[source]
genui.utils.gpu.info(device=None, memsort=False)[source]
genui.utils.gpu.release(device)[source]

genui.utils.init module

init

Created by: Martin Sicho On: 4/30/20, 7:16 PM

genui.utils.init.checkInitCondition(force)[source]
genui.utils.init.createGroup(groupName, models, permissions=('add', 'change', 'delete', 'view'), overwrite=True, appendPermissions=True, force=False)[source]

genui.utils.inspection module

inspection

Created by: Martin Sicho On: 4/30/20, 8:55 AM

genui.utils.inspection.discover_apps_urls(app_names, prefix='', app_names_as_root=False)[source]
genui.utils.inspection.discover_extensions(packages)[source]
genui.utils.inspection.discover_extensions_urlpatterns(parent)[source]
genui.utils.inspection.disover_app_urls_module(app_name, parent=None)[source]
genui.utils.inspection.findSubclassByID(base, module, id_attr: str, id_attr_val: str)[source]

Function to fetch a given class from a certain module. It is identified by both its base class and a value of a specific identifying attribute of the class.

Parameters
  • base – The base class of the class we are looking for.

  • module – Module containing the class of interest.

  • id_attr – The name of the identifying attribute on the class.

  • id_attr_val – The value of the searched attribute.

Returns

genui.utils.inspection.getFullName(obj, moduleOnly=False)[source]
genui.utils.inspection.getObjectAndModuleFromFullName(name)[source]
genui.utils.inspection.getSubclasses(cls)[source]

Fetch all existing subclasses of a class.

Parameters

cls

Returns

genui.utils.inspection.getSubclassesFromModule(base_cls, module)[source]

Fetch all subclasses of a given base class from a module.

Parameters
  • base_cls – The base class.

  • module – The module.

Returns

genui.utils.inspection.importFromPackage(package, module_name, exception=True)[source]
genui.utils.inspection.importModuleWithException(module, *args, message=True, throw=False, **kwargs)[source]

genui.utils.models module

models

Created by: Martin Sicho On: 1/12/20, 3:16 PM

genui.utils.models.NON_POLYMORPHIC_CASCADE(collector, field, sub_objs, using)[source]

This is a special cascade implementation to fix some delete errors when cascading polymorphic models.

See: https://github.com/django-polymorphic/django-polymorphic/issues/229#issuecomment-398434412

Parameters
  • collector

  • field

  • sub_objs

  • using

Returns

class genui.utils.models.OverwriteStorage(*args, **kwargs)[source]

Bases: FileSystemStorage

get_available_name(name, **kwargs)[source]

Returns a filename that’s free on the target storage system, and available for new content to be written to.

Found at http://djangosnippets.org/snippets/976/

This file storage solves overwrite on upload problem. Another proposed solution was to override the save method on the model like so (from https://code.djangoproject.com/ticket/11663):

def save(self, *args, **kwargs):
try:

this = MyModelName.objects.get(id=self.id) if this.MyImageFieldName != self.MyImageFieldName:

this.MyImageFieldName.delete()

except: pass super(MyModelName, self).save(*args, **kwargs)

genui.utils.pagination module

pagination

Created by: Martin Sicho On: 5/6/20, 10:55 AM

class genui.utils.pagination.GenuiPagination[source]

Bases: PageNumberPagination

get_url()[source]
page_size = 10

genui.utils.serializers module

serializers

Created by: Martin Sicho On: 12/22/19, 6:26 PM

class genui.utils.serializers.GenericModelSerializerMixIn[source]

Bases: object

className = CharField(allow_blank=True, required=False)
extraArgs = DictField(allow_empty=True, required=False)
getBaseSerializerClass(instance, extraFields)[source]
getClassNameRepresentation(instance)[source]
getExtraFieldsRepresentation(instance)[source]
to_representation(instance)[source]

genui.utils.tests module

class genui.utils.tests.GPUTests(methodName='runTest')[source]

Bases: TestCase

test_info()[source]

genui.utils.urls module

urls

Created by: Martin Sicho On: 5/3/20, 5:34 PM

genui.utils.views module

Module contents