renamed parse_channel_list_file -> load_channels; deprecated slic.utils.channels.Channels

This commit is contained in:
2021-07-25 18:53:42 +02:00
parent 37d931b556
commit e8a6623d2b
2 changed files with 14 additions and 4 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
from abc import ABC, abstractmethod
from collections import namedtuple
from slic.utils.printing import format_header, itemize
from slic.utils.channels import parse_channel_list_file
from slic.utils.channels import load_channels
import colorama
@@ -21,7 +21,7 @@ class Channels(list, ABC):
@classmethod
def from_file(cls, fname):
channels = parse_channel_list_file(fname)
channels = load_channels(fname)
return cls(*channels)
def __repr__(self):
+12 -2
View File
@@ -1,5 +1,7 @@
import warnings
def parse_channel_list_file(fname):
def load_channels(fname):
out = set()
with open(fname, "r") as f:
for line in f:
@@ -11,10 +13,18 @@ def parse_channel_list_file(fname):
return sorted(out)
message = """\
The class slic.utils.Channels is deprecated.
Please use, whichever appropriate, slic.core.acquisition.BSChannel, slic.core.acquisition.PVChannel or slic.utils.load_channels instead.
"""
class Channels(list):
def __init__(self, fname):
chs = parse_channel_list_file(fname)
warnings.warn(message, DeprecationWarning, stacklevel=2)
chs = load_channels(fname)
self.extend(chs)