Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

# Copyright (c) 2014, Facebook, Inc.  All rights reserved. 

# 

# This source code is licensed under the BSD-style license found in the 

# LICENSE file in the root directory of this source tree. An additional grant 

# of patent rights can be found in the PATENTS file in the same directory. 

# 

"""Run-time compatiblity helpers with third-party modules 

 

For most standard library moves and discrepancies, you should use `six` instead 

""" 

 

try: 

    from collections import OrderedDict 

except ImportError: 

    # Python2.6 compatibility 

    from ordereddict import OrderedDict 

 

try: 

    from subprocess import check_output 

except ImportError: 

    import subprocess 

 

    def check_output(args, stdin=None, stderr=None, shell=False, 

                     universal_newlines=False): 

        """Mostly compatible `check_output` for python2.6""" 

        p = subprocess.Popen(args, stdin=stdin, stderr=stderr, shell=shell, 

              universal_newlines=universal_newlines) 

        output, stderr = p.communicate() 

        returncode = p.wait() 

        if returncode != 0: 

            raise subprocess.CalledProcessError(returncode, cmd=args, output=output) 

        return output