-
Notifications
You must be signed in to change notification settings - Fork 176
Gathering some reusable functions in a utilities package (RFC)
RFC #13
Authors: P. Gay
Last Modified: 2013-04-18
Development of various interfaces (DIRAC commands, COMDIRAC commands, DIRAC.API, Rest, etc...) can lead to duplicate large portions of code. This could be avoided by gathering these functions inside a package that could be used in a standard way from other DIRAC interfaces.
An example of such a code duplication arises from the COMDIRAC (https://github.com/DIRACGrid/COMDIRAC) package commands that intensively reuses FileCatalogClientCLI methods. When it is needed to adapt these methods behaviour, for example changing output format of the method, this would require to copy the method's code into COMDIRAC package.
To solve this problem, various packages could be created inside Interfaces/Utilities/
source directory.
For example, there could be a Interfaces/Utilities/FileCatalogUtilities.py
module providing a buildMetaDict()
function that could build a metadata query dictionary from commandline arguments (and replace the FileCatalogClientCLI.__createQuery()
method). This function could then be reused in command dfind
with a different output than FileCatalogClientCLI.do_find()
.