libjam 0.0.5__tar.gz → 0.0.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
1
  __pycache__
2
- dist
2
+ dist
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: libjam
3
- Version: 0.0.5
3
+ Version: 0.0.7
4
4
  Summary: A library jam for Python.
5
5
  Project-URL: Homepage, https://github.com/philippkosarev/libjam
6
6
  Project-URL: Issues, https://github.com/philippkosarev/libjam/issues
@@ -15,6 +15,12 @@ Description-Content-Type: text/markdown
15
15
  # libjam
16
16
  A library jam for Python.
17
17
 
18
+ ## Installing
19
+ libjam is available on [pypi](https://pypi.org/project/libjam/), and can be installed using pip.
20
+ ```
21
+ pip install libjam
22
+ ```
23
+
18
24
  ## Modules
19
25
  libjam consists of of 6 modules:
20
26
 
@@ -1,6 +1,12 @@
1
1
  # libjam
2
2
  A library jam for Python.
3
3
 
4
+ ## Installing
5
+ libjam is available on [pypi](https://pypi.org/project/libjam/), and can be installed using pip.
6
+ ```
7
+ pip install libjam
8
+ ```
9
+
4
10
  ## Modules
5
11
  libjam consists of of 6 modules:
6
12
 
@@ -1,5 +1,5 @@
1
1
  # Imports
2
- import os, tomllib, configparser
2
+ import os, tomllib, configparser, json, ast
3
3
  from .drawer import Drawer
4
4
 
5
5
  # Jam classes
@@ -63,6 +63,7 @@ class Notebook:
63
63
  data[section] = keys
64
64
  return data
65
65
 
66
+ # Writes an ini file from a given dict to a given path.
66
67
  def write_ini(self, ini_file: str, contents: dict):
67
68
  if drawer.is_file(ini_file) is False:
68
69
  return None
@@ -76,3 +77,18 @@ class Notebook:
76
77
  parser[section][var_name] = value
77
78
  with open(ini_file, 'w') as file:
78
79
  parser.write(file)
80
+
81
+ # Reads a given json file as a dictionary.
82
+ def read_json(self, json_file: str):
83
+ if drawer.is_file(json_file) is False:
84
+ return None
85
+ json_file = os.path.normpath(json_file)
86
+ json_string = open(json_file, 'r').read()
87
+ try:
88
+ data = json.loads(json_string)
89
+ except json.decoder.JSONDecodeError:
90
+ json_string = json_string.replace('\n', ' ')
91
+ data = ast.literal_eval(json_string)
92
+ except:
93
+ data = None
94
+ return data
@@ -14,7 +14,7 @@ include = [
14
14
 
15
15
  [project]
16
16
  name = "libjam"
17
- version = "0.0.5"
17
+ version = "0.0.7"
18
18
  authors = [
19
19
  { name="Philipp Kosarev", email="philipp.kosarev@gmail.com" },
20
20
  ]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes