Skip to main content

kvk file handler

Project description

KvK

KvK file handler

Installation:

$ pip install kvk

KvK file example (file.kvk):

<#
    class "example" ::>
        (id) -> "0"
        (available) -> "true"
    class "anotherExample" ::>
        (id) -> "1"
        (accessible) -> "true"
#>

Creation of KvK object:

import kvk
fileHandler = kvk.KvK('file.kvk')

Read a KvK file:

fileHandler.read()
# output: [{'example':{'id':'0', 'available':'true'}}, {'anotherExample':{'id':'1', 'accessible':'true'}}]

Write a KvK file:

fileHandler.write(content=[{'newClass':{'id':'2', 'trust':'true'}}, {'anotherNewClass':{'id':'3', 'available':'true'}}]
  • The file content is removed and replaced with the new content

Get a class or an attribute from file:

fileHandler.get(element='newClass')
# output: {'id':'2', 'trust':'true'}

fileHandler.get(element='id', className='anotherNewClass')
# output: 3

Add a class:

fileHandler.addClass(className='addedClass')
  • Adds the class to the end of the file

Add an attribute:

fileHandler.addAttr(className='addedClass', attrName='addedAttribute', attrContent='first')
  • The attributes are added at the top of the class, before the existing arguments

Edit a class:

fileHandler.editClass(oldClassName='addedClass', newClassName='editedClass')

Edit an attribute:

fileHandler.editAttr(className='editedClass', oldAttrName='addedAttribute', newAttrName='editedAttribute', attrContent='alwaysFirst')
  • Changing the attribute content is not required

Remove a class:

fileHandler.removeClass(className='editedClass')
  • Removes both class and related attributes

Remove an attribute:

fileHandler.removeAttr(className='anotherNewClass', attrName='available')

Check if empty or not

fileHandler.isEmpty()
# output: False

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kvk-1.3.2.tar.gz (4.6 kB view hashes)

Uploaded Source

Built Distribution

kvk-1.3.2-py3-none-any.whl (5.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page