O2-DQ User Interface 1.0.0
Loading...
Searching...
No Matches
stringOperations.py
Go to the documentation of this file.
1#!/usr/bin/env python
2# PYTHON_ARGCOMPLETE_OK
3# -*- coding: utf-8 -*-
4
5# Copyright 2019-2020 CERN and copyright holders of ALICE O2.
6# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
7# All rights not expressly granted are reserved.
8#
9# This software is distributed under the terms of the GNU General Public
10# License v3 (GPL Version 3), copied verbatim in the file "COPYING".
11#
12# In applying this license CERN does not waive the privileges and immunities
13# granted to it by virtue of its status as an Intergovernmental Organization
14# or submit itself to any jurisdiction.
15
16# This script includes string operations for logic
17
18
19def listToString(s: list):
20 """
21 ListToString provides converts lists to strings with commas.
22 This function is written to save as string type instead of list
23
24
25 Args:
26 s (list): Input as List
27
28 Returns:
29 string: Comma seperated string
30 """
31 if len(s) > 1:
32 # initialize an empty string
33 str1 = ","
34
35 # return string
36 return str1.join(s)
37 else:
38 str1 = " "
39
40 return str1.join(s)
41
42
43def stringToList(string: str):
44 """
45 stringToList provides converts strings to list with commas.
46 This function is written to save as list type instead of string
47
48 Args:
49 string (string): Input as String
50
51 Returns:
52 list: merge string elements with comma
53 """
54 li = list(string.split(","))
55 return li