### Install/Upgrade Package Source: https://github.com/robotframework/pythonlibcore/blob/main/BUILD.md Test the installation of the package from PyPI using pip. Use the '--pre' flag to install pre-releases. ```bash pip install --upgrade robotframework-pythonlibcore ``` -------------------------------- ### Install Development Dependencies Source: https://github.com/robotframework/pythonlibcore/blob/main/BUILD.md Installs all necessary development tools and modules using pip and the provided requirements file. ```bash pip install -r requirements-dev.txt ``` -------------------------------- ### Library Components Example Source: https://github.com/robotframework/pythonlibcore/blob/main/README.md Shows how to define library components with keywords using the @keyword decorator. This includes examples of simple keywords, keywords with arguments and defaults, and keywords with custom names and tags. Methods not decorated with @keyword are not exposed as Robot Framework keywords. ```python from robotlibcore import keyword class Library1(object): @keyword def example(self): """Keyword documentation.""" pass @keyword def another_example(self, arg1, arg2='default'): pass def not_keyword(self): pass class Library2(object): @keyword('Custom name') def this_name_is_not_used(self): pass @keyword(tags=['tag', 'another']) def tags(self): pass ``` -------------------------------- ### DynamicCore Example Source: https://github.com/robotframework/pythonlibcore/blob/main/README.md Demonstrates how to initialize a library using DynamicCore, including importing and instantiating other libraries as components. Keywords can be defined directly in the main class using the @keyword decorator. ```python from robotlibcore import DynamicCore from mystuff import Library1, Library2 class MyLibrary(DynamicCore): """General library documentation.""" def __init__(self): libraries = [Library1(), Library2()] DynamicCore.__init__(self, libraries) @keyword def keyword_in_main(self): pass ``` -------------------------------- ### Listener Example Initialization Source: https://github.com/robotframework/pythonlibcore/blob/main/README.md Initializes a dynamic core library that also acts as a listener. The ROBOT_LIBRARY_LISTENER attribute is set to the instance itself. ```python from robot.running.model import TestCase from robot.result.model import TestCase as TestCaseResult from robotlibcore import DynamicCore, keyword class ListenerExample(DynamicCore): ROBOT_LIBRARY_SCOPE = 'GLOBAL' def __init__(self): self.ROBOT_LIBRARY_LISTENER = self components = [KeywordsWithListener()] super().__init__(components) class KeywordsWithListener: ROBOT_LISTENER_API_VERSION = 3 def __init__(self): self.test = None def start_test(self, data: TestCase, result: TestCaseResult): self.test = data.name self.passed = result.passed @keyword def keyword_with_listener(self, name: str, status: bool): assert name == self.test, f"Test case name {name} does not match expected {self.test}" assert status == self.passed, f"Test case status {status} does not match expected {self.passed} {type(self.passed)}" ``` -------------------------------- ### Install Latest Python Library Core Source: https://github.com/robotframework/pythonlibcore/blob/main/docs/PythonLibCore-4.6.0.md Use this command to install the latest available release of robotframework-pythonlibcore. Ensure pip is up-to-date. ```bash pip install --upgrade pip install robotframework-pythonlibcore ``` -------------------------------- ### Example Library Definition Source: https://github.com/robotframework/pythonlibcore/blob/main/README.md Defines a sample Python library with keywords, including one with a changed name and documentation. ```python from robotlibcore import DynamicCore, keyword class SmallLibrary(DynamicCore): """Library documentation.""" def __init__(self): """__init__ documentation.""" DynamicCore.__init__(self, []) @keyword(tags=["tag1", "tag2"]) def normal_keyword(self, arg: int, other: str) -> str: """I have doc Multiple lines. Other line. """ data = f"{arg} {other}" print(data) return data def not_keyword(self, data: str) -> str: print(data) return data @keyword(name="This Is New Name", tags=["tag1", "tag2"]) def name_changed(self, some: int, other: int) -> int: """This one too""" print(f"{some} {type(some)}, {other} {type(other)}") return some + other ``` -------------------------------- ### Translation JSON File Example Source: https://github.com/robotframework/pythonlibcore/blob/main/README.md Shows the structure of a JSON file used for translating keyword names and documentation. ```json // my_translation.json { "normal_keyword": { "name": "other_name", "doc": "This is new doc" }, "name_changed": { "name": "name_changed_again", "doc": "This is also replaced.\n\nnew line." }, "__init__": { "name": "__init__", "doc": "Replaces init docs with this one." }, "__intro__": { "name": "__intro__", "doc": "New __intro__ documentation is here." } } ``` -------------------------------- ### Install Specific Version of Python Library Core Source: https://github.com/robotframework/pythonlibcore/blob/main/docs/PythonLibCore-4.6.0.md Use this command to install exactly version 4.6.0 of robotframework-pythonlibcore. This ensures compatibility with this specific release. ```bash pip install pip install robotframework-pythonlibcore==4.6.0 ``` -------------------------------- ### Example Plugin Class Source: https://github.com/robotframework/pythonlibcore/blob/main/README.md A simple plugin class with a keyword. This class can be imported and used by a plugin library. ```python class MyPlugi: @keyword def plugin_keyword(self): return 123 ``` -------------------------------- ### Library Initialization with JSON File Path Source: https://github.com/robotframework/pythonlibcore/blob/main/README.md Demonstrates initializing the library using a path to a JSON translation file. ```python from pathlib import Path class SmallLibrary(DynamicCore): """Library documentation.""" def __init__(self): """__init__ documentation.""" DynamicCore.__init__(self, [], translation=Path("/path/to/my_translation.json")) # ... ``` -------------------------------- ### Create Distributions Source: https://github.com/robotframework/pythonlibcore/blob/main/BUILD.md Use 'uv build' to create source distributions and universal wheels. Verify the created files using 'ls -l dist'. ```bash uv build ls -l dist ``` -------------------------------- ### Library Initialization with Parsed YAML Data Source: https://github.com/robotframework/pythonlibcore/blob/main/README.md Demonstrates initializing the library with translation data loaded from a YAML file using PyYAML. ```python import yaml from pathlib import Path class SmallLibrary(DynamicCore): """Library documentation.""" def __init__(self, translation_file: Path): """__init__ documentation.""" translation_data = yaml.safe_load(translation_file.read_text(encoding="utf-8")) DynamicCore.__init__(self, [], translation=translation_data) # ... ``` -------------------------------- ### Library Initialization with Translation Dictionary Source: https://github.com/robotframework/pythonlibcore/blob/main/README.md Shows how to load translation data from a JSON file into a dictionary and pass it to the library constructor. ```python import json from pathlib import Path class SmallLibrary(DynamicCore): """Library documentation.""" def __init__(self): """__init__ documentation.""" translation_data = json.loads(Path("/path/to/my_translation.json").read_text(encoding="utf-8")) DynamicCore.__init__(self, [], translation=translation_data) # ... ``` -------------------------------- ### Generate Release Notes Source: https://github.com/robotframework/pythonlibcore/blob/main/BUILD.md Generates a template for release notes using Invoke. It requires GitHub credentials and the version number. The '-w' flag writes to a file, while omitting it prints to the console. Preview releases consider specific labels. ```bash GITHUB_USERNAME= GITHUB_PASSWORD= invoke release-notes -w -v $VERSION -u $GITHUB_USERNAME -p $GITHUB_PASSWORD ``` -------------------------------- ### Importing Plugin Library in Robot Framework Source: https://github.com/robotframework/pythonlibcore/blob/main/README.md Demonstrates how to import a plugin library in Robot Framework, specifying the plugin file path. ```robotframework Library ${CURDIR}/PluginLib.py plugins=${CURDIR}/MyPlugin.py ``` -------------------------------- ### Plugin Library Initialization Source: https://github.com/robotframework/pythonlibcore/blob/main/README.md Initializes a dynamic core library with external plugins. Plugins are parsed and added to the list of libraries. ```python from robot.api.deco import keyword # noqa F401 from robotlibcore import DynamicCore, PluginParser from mystuff import Library1, Library2 class PluginLib(DynamicCore): def __init__(self, plugins): plugin_parser = PluginParser() libraries = [Library1(), Library2()] parsed_plugins = plugin_parser.parse_plugins(plugins) libraries.extend(parsed_plugins) DynamicCore.__init__(self, libraries) ``` -------------------------------- ### Upload Distributions to PyPI Source: https://github.com/robotframework/pythonlibcore/blob/main/BUILD.md Upload the created distributions to the Python Package Index (PyPI) using the 'twine upload' command. ```bash twine upload dist/* ``` -------------------------------- ### Create and Push Git Tag Source: https://github.com/robotframework/pythonlibcore/blob/main/BUILD.md Use this command to create an annotated Git tag for a specific version and push it to the repository. ```bash git tag -a v$VERSION -m "Release $VERSION" git push --tags ``` -------------------------------- ### Commit and Push Release Notes Source: https://github.com/robotframework/pythonlibcore/blob/main/BUILD.md Adds the generated release notes file to Git, commits the changes with a descriptive message, and pushes the commit to the repository. ```bash git add docs/PythonLibCore-$VERSION.md git commit -m "Release notes for $VERSION" docs/PythonLibCore-$VERSION.md git push ``` -------------------------------- ### Checkout Git Tag Source: https://github.com/robotframework/pythonlibcore/blob/main/BUILD.md Checkout a previously created Git tag to prepare for building distributions. This is useful if you are not continuing directly after tagging. ```bash git checkout v$VERSION ``` -------------------------------- ### Clean Project Source: https://github.com/robotframework/pythonlibcore/blob/main/BUILD.md Executes the clean task using Invoke to remove temporary files and build artifacts. ```bash invoke clean ``` -------------------------------- ### Set Development Version Source: https://github.com/robotframework/pythonlibcore/blob/main/BUILD.md Update the project to the next development version using 'invoke set-version dev'. This is followed by a commit and push. ```bash invoke set-version dev git commit -m "Back to dev version" src/robotlibcore/__init__.py git push ``` -------------------------------- ### Commit and Push Version Update Source: https://github.com/robotframework/pythonlibcore/blob/main/BUILD.md Commits the changes made to the __init__.py file, which includes the updated version number, and pushes the commit to the repository. ```bash git commit -m "Updated version to $VERSION" src/robotlibcore/__init__.py git push ``` -------------------------------- ### Translation Data from YAML Source: https://github.com/robotframework/pythonlibcore/blob/main/README.md Illustrates providing translation data using a YAML format, which can then be parsed into a dictionary. ```yaml normal_keyword: name: other_name doc: This is new doc name_changed: name: name_changed_again doc: | This is also replaced. new line. __init__: name: __init__ doc: Replaces init docs with this one. __intro__: name: __intro__ doc: New __intro__ documentation is here. ``` -------------------------------- ### Basic Git Status Checks Source: https://github.com/robotframework/pythonlibcore/blob/main/BUILD.md Performs essential Git commands to ensure the local repository is clean and up-to-date before proceeding with release tasks. ```bash git branch git status git pull --rebase git push ``` -------------------------------- ### Checkout Master Branch Source: https://github.com/robotframework/pythonlibcore/blob/main/BUILD.md Return to the master branch after release actions are completed. ```bash git checkout master ``` -------------------------------- ### Set Release Version Source: https://github.com/robotframework/pythonlibcore/blob/main/BUILD.md Sets the version information for the PythonLibCore project using the Invoke tool. The version can include pre-release postfixes like 'aN', 'bN', or 'rcN'. ```bash VERSION= invoke set-version $VERSION ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.