# -*- coding: utf-8 -*-
'''

##########################
Acme::MetaSyntactic::linux
##########################

****
NAME
****


Acme::MetaSyntactic::linux - The Linux theme


***********
DESCRIPTION
***********


This theme contains the lists all the known and less
known Linux distributions, as maintained by DistroWatch on
`http://distrowatch.com/stats.php <http://distrowatch.com/stats.php>`_.

Note that the distribution list also contains the \*BSD projects.


***********
CONTRIBUTOR
***********


Philippe Bruhat (BooK).


*******
CHANGES
*******



- \*
 
 2019-10-28 - v1.035
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.054.
 


- \*
 
 2019-07-29 - v1.034
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.053.
 


- \*
 
 2018-10-29 - v1.033
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.052.
 


- \*
 
 2017-11-13 - v1.032
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.051.
 


- \*
 
 2017-06-12 - v1.031
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.050.
 


- \*
 
 2016-03-21 - v1.030
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.049.
 


- \*
 
 2015-10-19 - v1.029
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.048.
 


- \*
 
 2015-08-10 - v1.028
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.047.
 


- \*
 
 2015-06-08 - v1.027
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.046.
 


- \*
 
 2015-02-02 - v1.026
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.045.
 


- \*
 
 2015-01-05 - v1.025
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.044.
 


- \*
 
 2014-10-13 - v1.024
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.043.
 


- \*
 
 2014-09-15 - v1.023
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.042.
 


- \*
 
 2014-08-18 - v1.022
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.041.
 


- \*
 
 2014-06-16 - v1.021
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.040.
 


- \*
 
 2014-04-07 - v1.020
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.039.
 


- \*
 
 2013-12-09 - v1.019
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.038.
 


- \*
 
 2013-10-14 - v1.018
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.037.
 


- \*
 
 2013-09-16 - v1.017
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.036.
 


- \*
 
 2013-07-29 - v1.016
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.035.
 


- \*
 
 2013-07-22 - v1.015
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.034.
 


- \*
 
 2013-06-17 - v1.014
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.033.
 


- \*
 
 2013-06-03 - v1.013
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.032.
 


- \*
 
 2013-03-25 - v1.012
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.031.
 


- \*
 
 2013-02-18 - v1.011
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.030.
 


- \*
 
 2013-01-14 - v1.010
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.029.
 


- \*
 
 2012-11-19 - v1.009
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.028.
 


- \*
 
 2012-10-29 - v1.008
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.025.
 


- \*
 
 2012-10-22 - v1.007
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.024.
 


- \*
 
 2012-10-01 - v1.006
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.021.
 


- \*
 
 2012-09-10 - v1.005
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.018.
 


- \*
 
 2012-08-27 - v1.004
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.016.
 


- \*
 
 2012-07-23 - v1.003
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.011.
 


- \*
 
 2012-06-25 - v1.002
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.007.
 


- \*
 
 2012-05-28 - v1.001
 
 Updated from the source web site in Acme-MetaSyntactic-Themes version 1.003.
 


- \*
 
 2012-05-07 - v1.000
 
 Updated with new extraction code and changes since November 2006, and
 received its own version number in Acme-MetaSyntactic-Themes version 1.000.
 


- \*
 
 2006-11-06
 
 Updated from the source web site in Acme-MetaSyntactic version 0.99.
 


- \*
 
 2006-10-30
 
 Updated from the source web site in Acme-MetaSyntactic version 0.98.
 


- \*
 
 2006-10-23
 
 Updated from the source web site in Acme-MetaSyntactic version 0.97.
 


- \*
 
 2006-10-09
 
 Introduced in Acme-MetaSyntactic version 0.95.
 



**********
DEDICATION
**********


This module is dedicated to the Linux kernel for its fifteenth
anniversary. Linux was first published on the \ ``comp.archives``\  newsgroup
on October 5, 1991.
See `http://groups.google.com/group/comp.archives/msg/13a145b453f89094 <http://groups.google.com/group/comp.archives/msg/13a145b453f89094>`_

Linux was announced on \ ``comp.os.minix``\  on August 25, 1991.
See `http://groups.google.com/group/comp.os.minix/msg/b813d52cbc5a044b <http://groups.google.com/group/comp.os.minix/msg/b813d52cbc5a044b>`_


********
SEE ALSO
********


`Acme::MetaSyntactic <http://search.cpan.org/search?query=Acme%3a%3aMetaSyntactic&mode=module>`_, `Acme::MetaSyntactic::List <http://search.cpan.org/search?query=Acme%3a%3aMetaSyntactic%3a%3aList&mode=module>`_.
'''

name = 'linux'
DATA = '''\
# names
ThreeCX
FourMLinux
Absolute
AcademiX
AIO
Alpine
ALT
Android_x86
antiX
Arch
ArchBang
ArchLabs
Archman
ArchStrike
ArcoLinux
Artix
Arya
Asianux
AUSTRUMI
AV_Linux
BackBox
Baruwa
batocera
Bedrock
BeeFree
Berry
Bicom
BigLinux
BitKey
BlackArch
blackPanther
BlankOn
BlueOnyx
Bluestar
Bodhi
BOSS
BSDRP
BunsenLabs
CAELinux
CAINE
Calculate
Canaima
CentOS
Chakra
Clear
ClearOS
Clonezilla
ClonOS
CloudReady
Clu
Container
CRUX
Cucumber
Daphile
Debian
Debian_Edu
deepin
DEFT
Devuan
DietPi
DragonFly
Dragora
DRBL
DuZeru
EasyNAS
EasyOS
Elastix
elementary
Elive
Emmabuntus
EndeavourOS
Endian
Endless
Enso
EuroLinux
Exe
Exherbo
ExTiX
Fatdog64
Fedora
Feren
FreeBSD
FreedomBox
FreeNAS
FreePBX
Freespire
FuguIta
Funtoo
Gecko
GeeXboX
Gentoo
GhostBSD
GParted
Greenie
Grml
GuixSD
Haiku
Hamara
Hanthana
HardenedBSD
Hyperbola
IPFire
Kali
KANOTIX
KaOS
Karoshi
KDE_neon
KNOPPIX
Kodachi
KolibriOS
Kubuntu
Kwort
Lakka
LFS
LibreELEC
LinHES
Linspire
LinuxConsole
Linuxfx
Liquid_Lemur
Lite
Live_Raizo
LliureX
Lubuntu
Lunar
LXLE
Mageia
MakuluLinux
Manjaro
MAX
MidnightBSD
Minimal
MiniNo
Mint
MorpheusArch
MX_Linux
Namib
Neptune
NetBSD
NethServer
Netrunner
NexentaStor
Nitrux
NixOS
NomadBSD
Nova
NST
NuTyX
OB2D
Obarun
OLPC
Omarine
Omoikane
OpenBSD
OpenIndiana
openmamba
OpenMandriva
OpenMediaVault
openSUSE
Openwall
OPNsense
Oracle
OSGeoLive
OSMC
OviOS
paldo
Parabola
Pardus
Pardus_Topluluk
Parrot
Parted_Magic
PCLinuxOS
Peach_OSI
Pearl
Pentoo
Peppermint
pfSense
Photon
Pinguy
Pisi
Plamo
PLD
Plop
Pop_OS
Porteus
Porteus_Kiosk
Poseidon
PrimTux
Proxmox
Puppy
PureOS
Q4OS
Qubes
RancherOS
Raspbian
RDS
ReactOS
RebeccaBlackOS
Red_Hat
Redcore
Refracta
Rescatux
RISC
Robolinux
Rocks_Cluster
Rockstor
ROSA
RSS
Runtu
Sabayon
SalentOS
Secure_K
Securepoint
SELKS
Septor
Shark
siduction
Simplicity
Slackel
Slackware
Slax
SliTaz
SmartOS
SME_Server
Smoothwall
Solaris
Solus
SolydXK
Sophos
Source_Mage
SparkyLinux
Springdale
Star
SteamOS
Stella
Subgraph
Super_Grub2
SuperGamer
SuperX
SUSE
SystemRescue
T2
Tails
TalkingArch
TENS
Thinstation
Tiny_Core
ToOpPy
Trident
Trisquel
TrueOS
TurnKey
tuxtrans
UBOS
UBports
Ubuntu
Ubuntu_Budgie
Ubuntu_DP
Ubuntu_Kylin
Ubuntu_MATE
Ubuntu_Studio
Ultimate
Univention
Untangle
Uruk
VenenuX
Vine
Void
Volumio
Voyager
VyOS
Webconverger
Whonix
Wifislax
WM_Live
XigmaNAS
Xubuntu
YunoHost
Zentyal
Zenwalk
Zeroshell
Zevenet
Zorin\
'''

from metasyntactic.base import parse_data
from random import choice, shuffle
from six import iteritems
data = parse_data(DATA)


def default():
    try:
        if 'default' in data:
            return data['default'][0]
    except (KeyError, IndexError):
        pass
    return 'en'


def all():
    acc = set()
    for category, names in iteritems(data['names']):
        if names:
            acc |= names
    return acc


def names(category=None):
    if not category:
        category = default()
    if category == ':all':
        return list(all())
    category = category.replace('/', ' ')
    return list(data['names'][category])


def random(n=1, category=None):
    got = names(category)
    if got:
        shuffle(got)
        if n == 1:
            return choice(got)
        return got[:n]

def categories():
    return set(data['names'])


