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

####################################
Acme::MetaSyntactic::counting_to_one
####################################

****
NAME
****


Acme::MetaSyntactic::counting_to_one - The "movies where you count up to one" theme


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


This list gives the names of some movies
where you only need to count up to one or,
in some cases, up to zero. More precisely:

If you count the number of gunshots in \ *M\*A\*S\*H*\ 
(a Korean-war film), you obtain a count of one.

The same thing with \ *The Man Who Never Was*\  (a WWII movie)
gives a result of zero.

If you count the number of surviving characters at the end
of \ *The Trench*\ , you obtain a count of one.

If you count the number of female characters
in \ *Dr Strangelove*\ , you obtain a count of one.

On the other hand, if you count the number of male characters
in \ *Huit Femmes*\  (\ *Eight Women*\ ), you obtain a count of one.

If you count the number of times you see John Belushi's
eyes in \ *The Blues Brothers*\ , you obtain a count of one. If you prefer Dan Acroyd's
or Cab Calloway's eyes, you obtain a count of zero.

If you count the number of times the word "Mafia" is pronounced
in \ *The Godfather*\ , you obtain a count of zero.

If you count the number of alphabetic characters in Truffaut's
\ *Fahrenheit 451*\ , not taking into account the books
being burned, you obtain a count of zero.

If you count the number of scenes which include a horse in
\ *Monty Python's Holy Grail*\ , you obtain a count of one.

At the end of the same movie, if you count the number of names appearing in the final
credits, you obtain a count of zero.

If you count the number of words said during
Mel Brooks' \ *Silent Movie*\ , you obtain a count of one.

If you count the number of sexy scenes in \ *Robin Hood*\ 
(the Errol Flynn and Olivia de Havilland version), you obtain a count of one.

If you count the number of times Grace Kelly appears naked in
\ *The Bridges at Toko-Ri*\ , you obtain a count of one.

If you count the number of times Humphrey Bogart says "Play it again
Sam" in \ *Casablanca*\ , despite what the movie buff lore says, you
obtain a count of zero.

If you count the number of sequences in \ *Rope*\ ,
you obtain a count of one.

If you watch \ *Le Fils de Caroline Chrie*\  to have a look
at Caroline, you will see her only once.

In most war movies,
the delay between the instant you see an explosion and the
instant you hear it is zero seconds.

To these movies, we can add several other movies based
on Tennessee William's plays, which follow the
classical French theater's \ *rgle des trois units*\ :
one day, one place, one plot.

And of course, we can add any Buster Keaton film,
in which you might count the number of times Buster Keaton smiles,
as well as any Marx Brothers film, in which you can count the
number of times Harpo speaks.

Explanations
============



- M\*A\*S\*H
 
 The gunshot occurs during the football match, to mark the
 end of the first period of the game.
 


- The Man Who Never Was
 
 This movie is rather a spy movie that takes place during
 World War II. It presents the deception operation prior to
 the landing in Sicily, which consisted in releasing the
 corpse of a so-called "Major Martin", with forged secret
 documents, so this corpse would land in neutral Spain.
 The British hoped that the German agents in Spain would
 have access to the forged documents, believe them genuine
 and report their findings to Berlin. The movie describes
 the preparation of the operation and the mission of a
 German agent in England to check the background of "Major
 Martin". So, this film contains no gunshot, only one
 axis character and one corpse.
 


- The Trench
 
 This film describes the Somme Attack on 1st July, 1916, which may have
 been the most murderous day since the birth of mankind until the
 bombing of Hamburg in 1943. Therefore you might think that there would
 be no survivor among the main characters (that is, excluding the poge
 colonel and the cinema team). Yet, there is one survivor, the soldier
 who had his jaw smashed by a sniper shot and who was casevac'ed on the
 eve of the Somme attack.
 


- Dr Strangelove
 
 The female character is Miss "Foreign Affairs", General Turgidson's
 secretary, who appears also in the centerfold of the Playboy issue
 Major Kong is reading.
 See `http://tvtropes.org/pmwiki/pmwiki.php/Main/TheSmurfettePrinciple <http://tvtropes.org/pmwiki/pmwiki.php/Main/TheSmurfettePrinciple>`_
 


- The Blues Brothers
 
 The scene where we can see Jake's eyes is the scene in the sewer tunnel where
 Jake is at last face-to-face with his former wife-to-be, played by
 Carrie Fisher.
 


- Fahrenheit 451
 
 Ray Bradbury's book is about a future where books are banished,
 lest they'd be tought-provoking. Franois Truffaut's film is
 about a future where every single alphabetic character is banished,
 not only the thought-provoking ones inside the books, but also
 the utilitary characters such as "exit", "walk"/"don't walk",
 "in", "out". When a character's personal file is briefly shown,
 we can only see numbers. This goes to such length that the credits
 are not written on the screen, but spoken by a narrator.
 The contributor likes Ray Bradbury's book.
 


- Monty Python's Holy Grail
 
 The scene with a horse is the scene in which a professor
 is murdered. As for the final credits, there are none.
 


- Silent Movie
 
 The only word spoken during this film is Mime Marceau's answer
 to Mel Brooks: "No!"
 


- Robin Hood
 
 In this film, a "normal" scene is a scene where Maid Marian
 wears clothes and headgear covering everything except part of her face,
 from the forehead to the chin. A "sexy" scene is a scene
 in which Maid Marian appears with her whole bare head:
 face, ears, long flowing hear. Yet, from the neck down,
 she is still fully clothed.
 


- The Bridges at Toko-Ri
 
 This film includes a scene where Brubaker (William Holden), his wife
 (Grace Kelly) and their two girls take a Japanese bath. But don't
 hold your breath, the angles of view and the ripples in the water
 prevent you from seeing more than the Hays Code would permit.
 


- Rope
 
 This is a movie with five reels, yet with seemingly
 only one camera shot. Actually, from time to time,
 the camera zooms towards a dark object, such as
 James Stewart's suit or the lid of a wooden trunk.
 Then, when the camera zooms out, you notice a slightly
 different rendering of the colors. But it is customary
 to pretend not noticing that and to wonder how Hitchcock
 did this feat. The contributor does not agree. This movie
 is one of the few Hitchcock movies he dislikes.
 


- Le Fils de Caroline Chrie
 
 Actually, Caroline appears only something like 0.05 times,
 rounded up to one. The entire movie is about her son,
 living in Spain during the Napoleonic War and
 looking for his mother. His quest is fulfilled at
 the very end of the movie and he sees at last
 her mother exiting from a stagecoach. But you
 barely see her foot and ankle and the film
 ends on this picture. By the way, nothing
 ensures that this foot and this ankle are
 Martine Carol's (the actress playing Caroline
 in both other Caroline Chrie movies).
 




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


Jean Forget.


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



- \*
 
 2012-11-19 - v1.000
 
 Published as the last theme submitted before
 the release of Acme-MetaSyntactic version 0.99,
 in Acme-MetaSyntactic-Themes version 1.028.
 


- \*
 
 2012-10-21
 
 Jean selected \ *counting_to_one*\  as the theme name.
 


- \*
 
 2012-09-25
 
 Updated version submitted by Jean Forget.
 


- \*
 
 2006-07-11
 
 Submitted by Jean Forget as the \ *movies*\  theme.
 



********
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 = 'counting_to_one'
DATA = '''\
# names
MASH
The_Man_Who_Never_Was
The_Trench
Dr_Strangelove
Huit_Femmes
The_Blues_Brothers
The_Godfather
Fahrenheit_451
Monty_Python_Holy_Grail
Silent_Movie
Robin_Hood
The_Bridges_at_Toko_Ri
Casablanca
Rope
Le_Fils_de_Caroline_Cherie
A_Streetcar_Named_Desire
The_Night_of_the_Iguana
Cat_on_a_hot_tin_Roof
Three_Ages
The_Navigator
College
Steamboat_Bill_Jr
The_Cameraman
Monkey_Business
Horse_Feathers
Duck_Soup
A_Night_at_the_Opera
Go_West
The_Big_Store
A_Night_in_Casablanca
Love_Happy\
'''

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'])


