- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
channel_ids = []
for article_category in article_categories:
a_cat = article_category.split(":")[-1] # get the article category,
# the format is TT:04000000:EKO
if a_cat in user["CHANNEL_CATEGORIES"]:
# the channel ids is a comma separated list
channel_ids.extend(user["CHANNEL_CATEGORIES"][a_cat].split(","))
channel_ids = list(set(channel_ids))
if not channel_ids: # there are not any categories to post this article
logging.warning("No categories found. Article"
" (" + xml_fullname + ") Discarded.")
move_file(xml_fullname,
user["FTP"]["DISC_FILE_DIR"])
return
channel_ids = list(set(channel_ids)) # removing duplicates
# removing potential empty tokens
channel_ids = list(filter(None, channel_ids))
Ну просто наверочку собрал все уникальные ids, которые не None. Хотя как там могли оказаться None непонятно, но когда это беспокоило "хороших" программистов.