From 5bd13154337395148a4b606b4c36d5582e6d07a3 Mon Sep 17 00:00:00 2001 From: Bee <10378052+bee-san@users.noreply.github.com> Date: Thu, 10 Sep 2020 12:30:33 +0100 Subject: [PATCH] Updated What to check before a pull request (markdown) --- What-to-check-before-a-pull-request.md | 42 +++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/What-to-check-before-a-pull-request.md b/What-to-check-before-a-pull-request.md index 3d8e105..73d8aca 100644 --- a/What-to-check-before-a-pull-request.md +++ b/What-to-check-before-a-pull-request.md @@ -17,4 +17,44 @@ So for example (taken from a PR): `unquote` will never fail, so it will always return _something_. We have had to implement our own check to see if unquote did anything, this way we can return None. # Dictionaries or Lists -If your code requires a dictionary or list of letters or alphabets or the likes, it should go into CipheyDists. \ No newline at end of file +If your code requires a dictionary or list of letters or alphabets or the likes, it should go into CipheyDists. + +[https://github.com/Ciphey/CipheyDists](https://github.com/Ciphey/CipheyDists) + +CipheyDists contains all the dictionaries / alphabets required by decoders. + +If you have a list in your code that's rather quite long, place it in the [lists directory](https://github.com/Ciphey/CipheyDists/tree/master/cipheydists/list) as a JSON file with an appropriate name. + +If you have a dictionary, place it in [translate](https://github.com/Ciphey/CipheyDists/tree/master/cipheydists/translate) with an appropriate name. + +Now you can call your dictionary / list. + +Your first step is to change the `__init__` of yourr code. Let's look at Galactic Decoder as an example. + +```python + def __init__(self, config: Config): + super().__init__(config) + self.GALACTIC_DICT = config.get_resource(self._params()["dict"], Translation) +``` + +You don't have to change much here. Just add in this variable and name it something appropriate. + +The next part requires some code. Change the `gatParams` method to look like this: + +```python + @staticmethod + def getParams() -> Optional[Dict[str, ParamSpec]]: + return { + "dict": ParamSpec( + desc="The galactic alphabet dictionary to use", + req=False, + default="cipheydists::translate::galactic", + ) + } +``` + +Fill out the description (what it is you're getting from CipheyDists), whether or not it is required for your program to run, and the location of it. + +In this case, the Galactic dictionary is in CipheyDists, it is in the translate subdirectory and it is called "galactic". If we look at the [code](https://github.com/Ciphey/CipheyDists/blob/master/cipheydists/translate/galactic.json) we can see this is true. + +This is our [resource loader](https://github.com/Ciphey/Ciphey/wiki/Extending-Ciphey#resourceloader). You don't need to know much about it, other than it allows you to select resources without memorising weird file paths. \ No newline at end of file