~bennabiy/+junk/python-xlib

« back to all changes in this revision

Viewing changes to .pc/python3.patch/Xlib/support/connect.py

  • Committer: Package Import Robot
  • Author(s): Andrew Shadura, Ramkumar Ramachandra, Andrew Shadura
  • Date: 2015-08-13 08:14:19 UTC
  • mfrom: (6.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20150813081419-hdefinnghp2iydkx
Tags: 0.14+20091101-3
[ Ramkumar Ramachandra ]
* Remove useless debugging output (Closes: #565996)

[ Andrew Shadura ]
* Switch to 3.0 (quilt) format.
* Rename patches.
* Use debhelper 9 in its short form.
* Use pybuild.
* Bump Standards-Version.
* Don't build or install PostScript documentation and info files.
* Use system-provided texi2html instead of a shipped version
  (Closes: #795057).
* Update debian/copyright (Closes: #795057).
* Don't install Makefile or texi2html with the documentation.
* Set executable bit for examples.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Xlib.support.connect -- OS-independent display connection functions
 
2
#
 
3
#    Copyright (C) 2000 Peter Liljenberg <petli@ctrl-c.liu.se>
 
4
#
 
5
#    This program is free software; you can redistribute it and/or modify
 
6
#    it under the terms of the GNU General Public License as published by
 
7
#    the Free Software Foundation; either version 2 of the License, or
 
8
#    (at your option) any later version.
 
9
#
 
10
#    This program is distributed in the hope that it will be useful,
 
11
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
#    GNU General Public License for more details.
 
14
#
 
15
#    You should have received a copy of the GNU General Public License
 
16
#    along with this program; if not, write to the Free Software
 
17
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
 
 
19
import sys
 
20
import string
 
21
 
 
22
# List the modules which contain the corresponding functions
 
23
 
 
24
_display_mods = {
 
25
    'OpenVMS': 'vms_connect',
 
26
    }
 
27
 
 
28
_default_display_mod = 'unix_connect'
 
29
 
 
30
_socket_mods = {
 
31
    'OpenVMS': 'vms_connect'
 
32
    }
 
33
 
 
34
_default_socket_mod = 'unix_connect'
 
35
 
 
36
_auth_mods = {
 
37
    'OpenVMS': 'vms_connect'
 
38
    }
 
39
 
 
40
_default_auth_mod = 'unix_connect'
 
41
 
 
42
 
 
43
# Figure out which OS we're using.
 
44
# sys.platform is either "OS-ARCH" or just "OS".
 
45
 
 
46
_parts = string.split(sys.platform, '-')
 
47
platform = _parts[0]
 
48
del _parts
 
49
 
 
50
 
 
51
def get_display(display):
 
52
    """dname, host, dno, screen = get_display(display)
 
53
 
 
54
    Parse DISPLAY into its components.  If DISPLAY is None, use
 
55
    the default display.  The return values are:
 
56
 
 
57
      DNAME  -- the full display name (string)
 
58
      HOST   -- the host name (string, possibly empty)
 
59
      DNO    -- display number (integer)
 
60
      SCREEN -- default screen number (integer)
 
61
    """
 
62
 
 
63
    modname = _display_mods.get(platform, _default_display_mod)
 
64
    mod = __import__(modname, globals())
 
65
    return mod.get_display(display)
 
66
 
 
67
 
 
68
def get_socket(dname, host, dno):
 
69
    """socket = get_socket(dname, host, dno)
 
70
 
 
71
    Connect to the display specified by DNAME, HOST and DNO, which
 
72
    are the corresponding values from a previous call to get_display().
 
73
 
 
74
    Return SOCKET, a new socket object connected to the X server.
 
75
    """
 
76
 
 
77
    modname = _socket_mods.get(platform, _default_socket_mod)
 
78
    mod = __import__(modname, globals())
 
79
    return mod.get_socket(dname, host, dno)
 
80
 
 
81
 
 
82
def get_auth(sock, dname, host, dno):
 
83
    """auth_name, auth_data = get_auth(sock, dname, host, dno)
 
84
 
 
85
    Return authentication data for the display on the other side of
 
86
    SOCK, which was opened with DNAME, HOST and DNO.
 
87
 
 
88
    Return AUTH_NAME and AUTH_DATA, two strings to be used in the
 
89
    connection setup request.
 
90
    """
 
91
 
 
92
    modname = _auth_mods.get(platform, _default_auth_mod)
 
93
    mod = __import__(modname, globals())
 
94
    return mod.get_auth(sock, dname, host, dno)