Shopyoapi — Shopyo documentation

# Shopyoapi

Shopyo has some api which eases your life

## api.cmd

commandline utilities functions

`api.cmd.` `clean`(app)

  Deletes shopyo.db and migrations/ if present in current working directory. Deletes all __pycache__ folders starting from current working directory all the way to leaf directory.

  Parameters

    app (-) –

  Returns

    …

  Return type

    None

`api.cmd.` `collectstatic`(target_module=None)

  Copies `module/static` into `/static/modules/module`. In static it becomes like

      static/
           modules/
               box_something/
                   modulename
               modulename2

  Parameters

    target_module (str) – name of module, in alphanumeric-underscore, supports `module` or `box__name/module`

  Returns

  Return type

    None

`api.cmd.` `create_box`(name)

  creates box with box_info.json

  Parameters

    name (str) – name of box, in alphanumeric-underscore

  Returns

  Return type

    None

`api.cmd.` `create_module`(modulename, base_path=None)

  creates module with the structure defined in the modules section in docs

  Parameters

    modulename (str) – name of module, in alphanumeric-underscore

  Returns

  Return type

    None

`api.cmd.` `create_module_in_box`(modulename, boxname)

  creates module with the structure defined in the modules section in docs in a box

  Parameters

    - modulename (str) – name of module, in alphanumeric-underscore

    - boxname (str) – name of box, in alphanumeric-underscore

  Returns

  Return type

    None

`api.cmd.` `initialise`()

  Create db, migrate, adds default users, add settings

  Returns

  Return type

    None

## api.database

`api.database.` `autoload_models`()

  Auto imports models from modules/ in desired file. Used so that flask_migrate does not miss models when migrating

  Returns

  Return type

    None

## api.enhance

`api.enhance.` `base_context`()

  Used to define global template values

  Returns

    copy of dictionary

  Return type

    dict

`api.enhance.` `get_active_theme_dir`()

`api.enhance.` `set_setting`(key, value)

## api.file

`api.file.` `absdiroffile`(filepath)

  Gives absolute directory of file, normally expects __file__ as param

  Parameters

    filepath (str) – path of file

  Returns

    Absolute dir path of file

  Return type

    str

`api.file.` `delete_file`(path)

`api.file.` `get_folders`(path)

`api.file.` `trycopy`(source, dest, verbose=False)

  Non-ecursive copy of folder

  Parameters

    - source (str) – source folder path

    - dest (str) – destination folder path

  Returns

  Return type

    None

`api.file.` `trycopytree`(source, dest, verbose=False)

  Recursive copy of folder

  Parameters

    - source (str) – source folder path

    - dest (str) – destination folder path

  Returns

  Return type

    None

`api.file.` `trymkdir`(path, verbose=False)

  Creates dir at destination

  Parameters

    path (str) – path with folder already in

  Returns

  Return type

    None

`api.file.` `trymkfile`(path, content, verbose=False)

  Creates file

  Parameters

    - path (str) – path to create file with filename included

    - content (str) – file content

  Returns

  Return type

    None

`api.file.` `unique_filename`(fname)

## api.forms

`api.forms.` `flash_errors`(form)

  Auto flash errors from WKHtml forms Reqwires base module or similar notification mechanism

  Parameters

    form (WKHtml form) –

  Returns

  Return type

    None

## api.html

Used on flash flash(notify_success(‘mail sent!’))

`api.html.` `notify`(message, alert_type='primary')
  Used with flash

    flash(notify(‘blabla’))

  Parameters

    - message (str) – message to be displayed

    - alert_type (str) – bootstrap class

  Returns

  Return type

    None

`api.html.` `notify_danger`(message)

`api.html.` `notify_info`(message)

`api.html.` `notify_success`(message)

`api.html.` `notify_warning`(message)

## api.info

`api.info.` `printinfo`()

  prints Shopyo copyright in ASCII art font

## api.module

class `api.module.` `ModuleHelp`(dunderfile, dundername)

  Bases: `object`

  `context`()
  `get_self_static`(filename)
  `method`(methodname)
  `redirect_url`(url, **kwargs)
  `render`(filename, **kwargs)

    .render(‘file.html’) renders file.html found in module/templates/module/file.html