dictionary-file-lib


Namedictionary-file-lib JSON
Version 0.0.4 PyPI version JSON
download
home_page
SummaryKeywords lib to read a txt file
upload_time2023-01-20 15:45:14
maintainer
docs_urlNone
authorKaio Cândido Santiago
requires_python
licenseMIT License
keywords dictionary lib
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Official repository (Dictionary file)

<p align="center">
  <a href="" rel="noopener">
 <img width=200px height=200px src="https://i.imgur.com/6wj0hh6.jpg" alt="Project logo"></a>
</p>

<h3 align="center">Dicionary file</h3>



---

<p align="center"> Few lines describing your project.
    <br> 
</p>

## Table of Contents

- [About](#about)
- [Contributing](../CONTRIBUTING.md)
- [Authors](#authors)

## About <a name = "about"></a>

This project aims to manipulate files (txt and yaml) to save requests in a REST API.
Ex.: save the requests that will be used in a POST in a .txt file, thus making the project more organized.

### Prerequisites

- generate-lib
- Robotframework


### Installing

To install the library just use command line:
```
pip install dictionary-file
```
In addition to having python installed.
Obs.: You can create a python environment(recommended) or not.

## Running the tests <a name = "tests"></a>

To run the functions just import the library in your robotframework project.
```robotframework
*** Settings ***
Library    dictionary_file
*** Keywords ***
Library testing
    ${t}        CREATE DICT BY FILE TXT    file_name=${EMPTY}        full_path=C:\\Users\\Vericoders\\Documents\\test-lib\\dicionario.txt
    UPDATE DICTIONARY    ${t}     name=Yuri
    Log To Console    \n${t}
*** Test Cases ***
Scenario 01
    [Tags]        teste
    Library testing
```

The keyword (CREATE DICT FILE TXT) create a dictionary through txt file.
```python
def create_dict_by_file_txt(self, name_file: str, full_path: str = None) -> dict:
        if full_path is None:
            arq =  open(os.path.dirname(__file__) + f"/{name_file}", 'r')
        elif full_path is not None and name_file == "":
            arq =  open(f"{full_path}", 'r')
        lines = arq.readlines()
        dict_ = dict()
        for line in lines:
            if line is not None and "=" in line:
                list_kys_values = ''.join(line.replace(' ', '')).split(',')
                for item in list_kys_values:
                    key = item.split('=')[0]
                    value = item.split('=')[1]  
                    if "@" in value:
                        value =  generate_email_random(1)
                    if self.LINE_BREAK in value: 
                        value = value.replace(self.LINE_BREAK, '')
                    if value.startswith(self.STR):
                        value = value.replace(self.STR, '').replace(')', '')
                    if value.startswith(self.INT):
                        value = int(value.replace(self.INT, '').replace(')', ''))                                                          
                    dict_.update({key: value})               
            else:
                break
        return dict_
```
The file .txt needs to contains some features. Example:
```txt
name=str(kaio), email=str(kaio.santiago@hotmail.com), password=int(1234), admin=str(true)
```
Values of dict needs to be defined type as in the example above.
- string: str(<word>)
- int: int(number_int)
- bool: bool(true_or_false)

## Usage <a name="usage"></a>

Use to take information through txt file to create dictionary. This is useful to create requisition(dictionary) to test automation API REST. 

## Built Using <a name = "built_using"></a>

- [Python](https://docs.python.org/3/) - Programming language
- [Robot](https://robotframework.org/) - Automation Framework

## Authors <a name = "authors"></a>

- [@Kaio1394](https://github.com/Kaio1394) - Idea & Initial work

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "dictionary-file-lib",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "dictionary lib",
    "author": "Kaio C\u00e2ndido Santiago",
    "author_email": "kaio.santiago.13@hotmail.com",
    "download_url": "https://files.pythonhosted.org/packages/43/a7/3aabd05409ce7759abae254ade631c0f18b47a7b809a8cbd4b6dab95d9ca/dictionary-file-lib-0.0.4.tar.gz",
    "platform": null,
    "description": "# Official repository (Dictionary file)\r\n\r\n<p align=\"center\">\r\n  <a href=\"\" rel=\"noopener\">\r\n <img width=200px height=200px src=\"https://i.imgur.com/6wj0hh6.jpg\" alt=\"Project logo\"></a>\r\n</p>\r\n\r\n<h3 align=\"center\">Dicionary file</h3>\r\n\r\n\r\n\r\n---\r\n\r\n<p align=\"center\"> Few lines describing your project.\r\n    <br> \r\n</p>\r\n\r\n## Table of Contents\r\n\r\n- [About](#about)\r\n- [Contributing](../CONTRIBUTING.md)\r\n- [Authors](#authors)\r\n\r\n## About <a name = \"about\"></a>\r\n\r\nThis project aims to manipulate files (txt and yaml) to save requests in a REST API.\r\nEx.: save the requests that will be used in a POST in a .txt file, thus making the project more organized.\r\n\r\n### Prerequisites\r\n\r\n- generate-lib\r\n- Robotframework\r\n\r\n\r\n### Installing\r\n\r\nTo install the library just use command line:\r\n```\r\npip install dictionary-file\r\n```\r\nIn addition to having python installed.\r\nObs.: You can create a python environment(recommended) or not.\r\n\r\n## Running the tests <a name = \"tests\"></a>\r\n\r\nTo run the functions just import the library in your robotframework project.\r\n```robotframework\r\n*** Settings ***\r\nLibrary    dictionary_file\r\n*** Keywords ***\r\nLibrary testing\r\n    ${t}        CREATE DICT BY FILE TXT    file_name=${EMPTY}        full_path=C:\\\\Users\\\\Vericoders\\\\Documents\\\\test-lib\\\\dicionario.txt\r\n    UPDATE DICTIONARY    ${t}     name=Yuri\r\n    Log To Console    \\n${t}\r\n*** Test Cases ***\r\nScenario 01\r\n    [Tags]        teste\r\n    Library testing\r\n```\r\n\r\nThe keyword (CREATE DICT FILE TXT) create a dictionary through txt file.\r\n```python\r\ndef create_dict_by_file_txt(self, name_file: str, full_path: str = None) -> dict:\r\n        if full_path is None:\r\n            arq =  open(os.path.dirname(__file__) + f\"/{name_file}\", 'r')\r\n        elif full_path is not None and name_file == \"\":\r\n            arq =  open(f\"{full_path}\", 'r')\r\n        lines = arq.readlines()\r\n        dict_ = dict()\r\n        for line in lines:\r\n            if line is not None and \"=\" in line:\r\n                list_kys_values = ''.join(line.replace(' ', '')).split(',')\r\n                for item in list_kys_values:\r\n                    key = item.split('=')[0]\r\n                    value = item.split('=')[1]  \r\n                    if \"@\" in value:\r\n                        value =  generate_email_random(1)\r\n                    if self.LINE_BREAK in value: \r\n                        value = value.replace(self.LINE_BREAK, '')\r\n                    if value.startswith(self.STR):\r\n                        value = value.replace(self.STR, '').replace(')', '')\r\n                    if value.startswith(self.INT):\r\n                        value = int(value.replace(self.INT, '').replace(')', ''))                                                          \r\n                    dict_.update({key: value})               \r\n            else:\r\n                break\r\n        return dict_\r\n```\r\nThe file .txt needs to contains some features. Example:\r\n```txt\r\nname=str(kaio), email=str(kaio.santiago@hotmail.com), password=int(1234), admin=str(true)\r\n```\r\nValues of dict needs to be defined type as in the example above.\r\n- string: str(<word>)\r\n- int: int(number_int)\r\n- bool: bool(true_or_false)\r\n\r\n## Usage <a name=\"usage\"></a>\r\n\r\nUse to take information through txt file to create dictionary. This is useful to create requisition(dictionary) to test automation API REST. \r\n\r\n## Built Using <a name = \"built_using\"></a>\r\n\r\n- [Python](https://docs.python.org/3/) - Programming language\r\n- [Robot](https://robotframework.org/) - Automation Framework\r\n\r\n## Authors <a name = \"authors\"></a>\r\n\r\n- [@Kaio1394](https://github.com/Kaio1394) - Idea & Initial work\r\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Keywords lib to read a txt file",
    "version": "0.0.4",
    "split_keywords": [
        "dictionary",
        "lib"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "43a73aabd05409ce7759abae254ade631c0f18b47a7b809a8cbd4b6dab95d9ca",
                "md5": "c4e04645ff384cbe286e5a77e60af57c",
                "sha256": "d82a684c6064bf48c862aacb8dc09365891e262660e91866dc95b07613a8ba12"
            },
            "downloads": -1,
            "filename": "dictionary-file-lib-0.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "c4e04645ff384cbe286e5a77e60af57c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3991,
            "upload_time": "2023-01-20T15:45:14",
            "upload_time_iso_8601": "2023-01-20T15:45:14.209628Z",
            "url": "https://files.pythonhosted.org/packages/43/a7/3aabd05409ce7759abae254ade631c0f18b47a7b809a8cbd4b6dab95d9ca/dictionary-file-lib-0.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-20 15:45:14",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "dictionary-file-lib"
}
        
Elapsed time: 0.03253s