semvec/pypi-packages huggingface dataset:
dracodes 0.33
Automation helpers
License: MIT

[![PyPI](https://img.shields.io/pypi/v/dracodes.svg)](https://pypi.python.org/pypi/dracodes)

# Dracodes

One line solutions to speed up scripting

## Installation:

```
pip3 install dracodes
```

## Examples:

#### Writing into a file:

```python
aString = 'A normal phrase'
aList = ['jooj', 'cleyton', 'not foo', 'not bar']
aListOfNumbers = list(range(10))
aMixedList = ['hello', 123456789, ['nested1', 'nested2'], {'1': 2}]
aDictionary = {'key1': 1, 'key2': 'valu2', 'key3': [3]}

with open('path/out.txt') as outFile:
	outFile.write(f'{aString}\n')
    for item in aList:
    	outFile.write(f'{line}\n')
    for item in aListOfNumbers :
    	outFile.write(f'{str(line)}\n')
    for item in aMixedList:
    	if isinstance(item, str):
            outFile.write(f'{line}\n')
        if isistance(item, list):
        	for subItem in item:
            	# Ok, we get it
```

A lazy solution:

```python
from dracodes import saveOutput

output = tuple(aString, aList, aListOfNumbers, aMixedList, aDictionary)
saveOutput('path/out.txt', output) # by default in 'write' mode, but It is possible to set 'append' mode
```

#### Iterating over lines in a file:

Instead of:

```python
with open('path/file.txt') as file:
	for line in file:
   		# ...
```

You can use <code>iterFile</code>:

```python
from dracodes import iterFile

for line in iterFile('path/file.txt'):
	# ...
```

#### Indented Documents:

```python
text = """class Jooj(object):
    def __init__(self, message):
        self.message

    def notBar(self):
        print('Not a Bar')

    def notFoo(self):
        print('Not a Foo')"""

doc = IndentedDocument(text)

for line in doc:
    print(f'{line} | Depth: {line.depth}')
```

Output:

```
class Jooj(object): | Depth: 1
    def __init__(self, message): | Depth: 2
        self.message | Depth: 3
 | Depth: 3
    def notBar(self): | Depth: 2
        print('Not a Bar') | Depth: 3
 | Depth: 3
    def notFoo(self): | Depth: 2
        print('Not a Foo') | Depth: 3
```

---

Lucas Vargas Noronha