This file is indexed.

/usr/share/doc/python-apt-doc/html/library/apt_pkg.html is in python-apt-doc 1.1.0~beta1build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>apt_pkg — The low-level bindings for apt-pkg &mdash; python-apt 1.1.0~beta1build1 documentation</title>
    
    <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '1.1.0~beta1build1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="top" title="python-apt 1.1.0~beta1build1 documentation" href="../contents.html" />
    <link rel="up" title="Python APT Library" href="index.html" />
    <link rel="next" title="apt_inst - Working with local Debian packages" href="apt_inst.html" />
    <link rel="prev" title="Python APT Library" href="index.html" />
   
  
  <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9">

  </head>
  <body role="document">  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="module-apt_pkg">
<span id="apt-pkg-the-low-level-bindings-for-apt-pkg"></span><h1><a class="reference internal" href="#module-apt_pkg" title="apt_pkg"><code class="xref py py-mod docutils literal"><span class="pre">apt_pkg</span></code></a> &#8212; The low-level bindings for apt-pkg<a class="headerlink" href="#module-apt_pkg" title="Permalink to this headline"></a></h1>
<p>The apt_pkg extensions provides a more low-level way to work with apt. It can
do everything apt can, and is written in C++. It has been in python-apt since
the beginning.</p>
<div class="section" id="module-initialization">
<h2>Module Initialization<a class="headerlink" href="#module-initialization" title="Permalink to this headline"></a></h2>
<p>Initialization is needed for most functions, but not for all of them. Some can
be called without having run init*(), but will not return the expected value.</p>
<dl class="function">
<dt id="apt_pkg.init_config">
<code class="descclassname">apt_pkg.</code><code class="descname">init_config</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.init_config" title="Permalink to this definition"></a></dt>
<dd><p>Initialize the configuration of apt. This is needed for most operations.</p>
</dd></dl>

<dl class="function">
<dt id="apt_pkg.init_system">
<code class="descclassname">apt_pkg.</code><code class="descname">init_system</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.init_system" title="Permalink to this definition"></a></dt>
<dd><p>Initialize the system.</p>
</dd></dl>

<dl class="function">
<dt id="apt_pkg.init">
<code class="descclassname">apt_pkg.</code><code class="descname">init</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.init" title="Permalink to this definition"></a></dt>
<dd><p>A short cut to calling <a class="reference internal" href="#apt_pkg.init_config" title="apt_pkg.init_config"><code class="xref py py-func docutils literal"><span class="pre">init_config()</span></code></a> and <a class="reference internal" href="#apt_pkg.init_system" title="apt_pkg.init_system"><code class="xref py py-func docutils literal"><span class="pre">init_system()</span></code></a>. You
can use this if you do not use the command line parsing facilities provided
by <a class="reference internal" href="#apt_pkg.parse_commandline" title="apt_pkg.parse_commandline"><code class="xref py py-func docutils literal"><span class="pre">parse_commandline()</span></code></a>, otherwise call <a class="reference internal" href="#apt_pkg.init_config" title="apt_pkg.init_config"><code class="xref py py-func docutils literal"><span class="pre">init_config()</span></code></a>, parse
the commandline afterwards and finally call <a class="reference internal" href="#apt_pkg.init_system" title="apt_pkg.init_system"><code class="xref py py-func docutils literal"><span class="pre">init_system()</span></code></a>.</p>
</dd></dl>

</div>
<div class="section" id="working-with-the-cache">
<h2>Working with the cache<a class="headerlink" href="#working-with-the-cache" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="apt_pkg.Cache">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">Cache</code><span class="sig-paren">(</span><span class="optional">[</span><em>progress: apt.progress.base.OpProgress</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.Cache" title="Permalink to this definition"></a></dt>
<dd><p>A Cache object represents the cache used by APT which contains information
about packages. The object itself provides no means to modify the cache or
the installed packages, see the classes <a class="reference internal" href="#apt_pkg.DepCache" title="apt_pkg.DepCache"><code class="xref py py-class docutils literal"><span class="pre">DepCache</span></code></a> and
<a class="reference internal" href="#apt_pkg.PackageManager" title="apt_pkg.PackageManager"><code class="xref py py-class docutils literal"><span class="pre">PackageManager</span></code></a> for such functionality.</p>
<p>The constructor takes an optional argument which must be a subclass of
<a class="reference internal" href="apt.progress.base.html#apt.progress.base.OpProgress" title="apt.progress.base.OpProgress"><code class="xref py py-class docutils literal"><span class="pre">apt.progress.base.OpProgress</span></code></a>. This object will then be used to
display information during the cache opening process (or possible creation
of the cache). It may also be <code class="docutils literal"><span class="pre">None</span></code>, in which case no progress will
be emitted. If not given, progress will be printed to standard output.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The cache supports colon-separated name:architecture pairs. For
normal architectures, they are equal to a (name, architecture)
tuple. For the &#8220;any&#8221; architecture behavior is different, as
&#8220;name:any&#8221; is equivalent to (&#8220;name:any&#8221;, &#8220;any&#8221;). This is done so
that &#8220;name:any&#8221; matches all packages with that name which have
Multi-Arch: allowed set.</p>
</div>
<dl class="describe">
<dt>
<code class="descname">cache[pkgname]</code></dt>
<dd><p>Return the <a class="reference internal" href="#apt_pkg.Package" title="apt_pkg.Package"><code class="xref py py-class docutils literal"><span class="pre">Package()</span></code></a> object for the package name given by
<em>pkgname</em>. If <em>pkgname</em> includes a colon, the part after the colon
is used as the architecture.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="descname">cache[name, architecture]</code></dt>
<dd><p>Return the <a class="reference internal" href="#apt_pkg.Package" title="apt_pkg.Package"><code class="xref py py-class docutils literal"><span class="pre">Package()</span></code></a> object for the package with the given
name and architecture.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="descname">pkgname in cache</code></dt>
<dd><p>Check whether a package with the name given by <em>pkgname</em> exists in
the cache for the native architecture. If <em>pkgname</em> includes a
colon, the part after the colon is used as the architecture.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="descname">(name, architecture) in cache</code></dt>
<dd><p>Check whether a package with the given name and architecture exists
in the cache.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.Cache.update">
<code class="descname">update</code><span class="sig-paren">(</span><em>progress</em>, <em>sources</em><span class="optional">[</span>, <em>pulse_interval</em><span class="optional">]</span><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.Cache.update" title="Permalink to this definition"></a></dt>
<dd><p>Update the index files used by the cache. A call to this method
does not affect the current Cache object, instead a new one
should be created in order to use the changed index files.</p>
<p>The parameter <em>progress</em> takes an
<a class="reference internal" href="apt.progress.base.html#apt.progress.base.AcquireProgress" title="apt.progress.base.AcquireProgress"><code class="xref py py-class docutils literal"><span class="pre">apt.progress.base.AcquireProgress</span></code></a> object which will display
the progress of fetching the index files. The parameter <em>sources</em> takes
a <a class="reference internal" href="#apt_pkg.SourceList" title="apt_pkg.SourceList"><code class="xref py py-class docutils literal"><span class="pre">SourceList</span></code></a> object which lists the sources. The parameter
<em>progress</em> takes an integer describing the interval (in microseconds)
in which the pulse() method of the <em>progress</em> object will be called.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Cache.depends_count">
<code class="descname">depends_count</code><a class="headerlink" href="#apt_pkg.Cache.depends_count" title="Permalink to this definition"></a></dt>
<dd><p>The total number of dependencies stored in the cache.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Cache.file_list">
<code class="descname">file_list</code><a class="headerlink" href="#apt_pkg.Cache.file_list" title="Permalink to this definition"></a></dt>
<dd><p>A list of all <a class="reference internal" href="#apt_pkg.PackageFile" title="apt_pkg.PackageFile"><code class="xref py py-class docutils literal"><span class="pre">PackageFile</span></code></a> objects stored in the cache.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Cache.group_count">
<code class="descname">group_count</code><a class="headerlink" href="#apt_pkg.Cache.group_count" title="Permalink to this definition"></a></dt>
<dd><p>The number of groups in the cache.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Cache.groups">
<code class="descname">groups</code><a class="headerlink" href="#apt_pkg.Cache.groups" title="Permalink to this definition"></a></dt>
<dd><p>A sequence of <a class="reference internal" href="#apt_pkg.Group" title="apt_pkg.Group"><code class="xref py py-class docutils literal"><span class="pre">Group</span></code></a> objects, implemented as a
<a class="reference internal" href="#apt_pkg.Cache.GroupList" title="apt_pkg.Cache.GroupList"><code class="xref py py-class docutils literal"><span class="pre">GroupList</span></code></a> object.</p>
<dl class="class">
<dt id="apt_pkg.Cache.GroupList">
<em class="property">class </em><code class="descname">GroupList</code><a class="headerlink" href="#apt_pkg.Cache.GroupList" title="Permalink to this definition"></a></dt>
<dd><p>A simple sequence-like object which only provides a length and
an implementation of <code class="docutils literal"><span class="pre">__getitem__</span></code> for accessing groups at
a certain index. Apart from being iterable, it can be used in
the following ways:</p>
<dl class="describe">
<dt>
<code class="descname">list[index]</code></dt>
<dd><p>Get the <a class="reference internal" href="#apt_pkg.Group" title="apt_pkg.Group"><code class="xref py py-class docutils literal"><span class="pre">Group</span></code></a> object for the group at the position
given by <em>index</em> in the GroupList <em>list</em>.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="descname">len(list)</code></dt>
<dd><p>Return the length of the GroupList object <em>list</em>.</p>
</dd></dl>

</dd></dl>

</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.is_multi_arch">
<code class="descclassname">apt_pkg.</code><code class="descname">is_multi_arch</code><a class="headerlink" href="#apt_pkg.is_multi_arch" title="Permalink to this definition"></a></dt>
<dd><p>An attribute determining whether the cache supports multi-arch.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.package_count">
<code class="descclassname">apt_pkg.</code><code class="descname">package_count</code><a class="headerlink" href="#apt_pkg.package_count" title="Permalink to this definition"></a></dt>
<dd><p>The total number of packages available in the cache. This value is
equal to the length of the list provided by the <a class="reference internal" href="#apt_pkg.packages" title="apt_pkg.packages"><code class="xref py py-attr docutils literal"><span class="pre">packages</span></code></a>
attribute.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.package_file_count">
<code class="descclassname">apt_pkg.</code><code class="descname">package_file_count</code><a class="headerlink" href="#apt_pkg.package_file_count" title="Permalink to this definition"></a></dt>
<dd><p>The total number of Packages files available (the Packages files
listing the packages). This is the same as the length of the list in
the attribute <code class="xref py py-attr docutils literal"><span class="pre">file_list</span></code>.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.packages">
<code class="descclassname">apt_pkg.</code><code class="descname">packages</code><a class="headerlink" href="#apt_pkg.packages" title="Permalink to this definition"></a></dt>
<dd><p>A sequence of <a class="reference internal" href="#apt_pkg.Package" title="apt_pkg.Package"><code class="xref py py-class docutils literal"><span class="pre">Package</span></code></a> objects, implemented as a
<a class="reference internal" href="#apt_pkg.PackageList" title="apt_pkg.PackageList"><code class="xref py py-class docutils literal"><span class="pre">PackageList</span></code></a> object.</p>
<dl class="class">
<dt id="apt_pkg.PackageList">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">PackageList</code><a class="headerlink" href="#apt_pkg.PackageList" title="Permalink to this definition"></a></dt>
<dd><p>A simple sequence-like object which only provides a length and
an implementation of <code class="docutils literal"><span class="pre">__getitem__</span></code> for accessing packages at
a certain index. Apart from being iterable, it can be used in
the following ways:</p>
<dl class="describe">
<dt>
<code class="descname">list[index]</code></dt>
<dd><p>Get the <a class="reference internal" href="#apt_pkg.Package" title="apt_pkg.Package"><code class="xref py py-class docutils literal"><span class="pre">Package</span></code></a> object for the package at the position
given by <em>index</em> in the PackageList <em>list</em>.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="descname">len(list)</code></dt>
<dd><p>Return the length of the PackageList object <em>list</em>.</p>
</dd></dl>

</dd></dl>

</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.provides_count">
<code class="descclassname">apt_pkg.</code><code class="descname">provides_count</code><a class="headerlink" href="#apt_pkg.provides_count" title="Permalink to this definition"></a></dt>
<dd><p>The number of provided packages.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.ver_file_count">
<code class="descclassname">apt_pkg.</code><code class="descname">ver_file_count</code><a class="headerlink" href="#apt_pkg.ver_file_count" title="Permalink to this definition"></a></dt>
<dd><p>The total number of <code class="docutils literal"><span class="pre">(Version,</span> <span class="pre">PackageFile)</span></code> relations stored in
the cache.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.version_count">
<code class="descclassname">apt_pkg.</code><code class="descname">version_count</code><a class="headerlink" href="#apt_pkg.version_count" title="Permalink to this definition"></a></dt>
<dd><p>The total number of package versions available in the cache.</p>
</dd></dl>

</dd></dl>

<div class="section" id="managing-the-cache-with-depcache">
<h3>Managing the cache with <a class="reference internal" href="#apt_pkg.DepCache" title="apt_pkg.DepCache"><code class="xref py py-class docutils literal"><span class="pre">DepCache</span></code></a><a class="headerlink" href="#managing-the-cache-with-depcache" title="Permalink to this headline"></a></h3>
<dl class="class">
<dt id="apt_pkg.DepCache">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">DepCache</code><span class="sig-paren">(</span><em>cache: apt_pkg.Cache</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.DepCache" title="Permalink to this definition"></a></dt>
<dd><p>A DepCache object provides access to more information about the
objects made available by the <a class="reference internal" href="#apt_pkg.Cache" title="apt_pkg.Cache"><code class="xref py py-class docutils literal"><span class="pre">Cache</span></code></a> object as well as
means to mark packages for removal and installation, among other
actions.</p>
<p>The constructor takes a single argument which specifies the
<a class="reference internal" href="#apt_pkg.Cache" title="apt_pkg.Cache"><code class="xref py py-class docutils literal"><span class="pre">Cache</span></code></a> object the new object shall be related to. While
it is theoretically possible to create multiple DepCache objects
for the same cache, they will not be independent from each other
since they all access the same underlying C++ object.</p>
<p>Objects of this type provide several methods. Most of those methods
are safe to use and should never raise any exception (all those
methods for requesting state information or marking changes). If a
method is expected to raise an exception, it will be stated in the
description.</p>
<dl class="method">
<dt id="apt_pkg.DepCache.commit">
<code class="descname">commit</code><span class="sig-paren">(</span><em>acquire_progress</em>, <em>install_progress</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.DepCache.commit" title="Permalink to this definition"></a></dt>
<dd><p>Commit all marked changes, while reporting the progress of
fetching packages via the <a class="reference internal" href="apt.progress.base.html#apt.progress.base.AcquireProgress" title="apt.progress.base.AcquireProgress"><code class="xref py py-class docutils literal"><span class="pre">apt.progress.base.AcquireProgress</span></code></a>
object given by <em>acquire_progress</em> and reporting the installation
of the package using the <a class="reference internal" href="apt.progress.base.html#apt.progress.base.InstallProgress" title="apt.progress.base.InstallProgress"><code class="xref py py-class docutils literal"><span class="pre">apt.progress.base.InstallProgress</span></code></a>
object given by <em>install_progress</em>.</p>
<p>If this fails, an exception of the type <code class="xref py py-exc docutils literal"><span class="pre">SystemError</span></code> will
be raised.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.DepCache.fix_broken">
<code class="descname">fix_broken</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.DepCache.fix_broken" title="Permalink to this definition"></a></dt>
<dd><p>Try to fix all broken packages in the cache and return <code class="docutils literal"><span class="pre">True</span></code> in
case of success. If an error occurred, a <code class="xref py py-exc docutils literal"><span class="pre">SystemError</span></code>
exception is raised.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.DepCache.get_candidate_ver">
<code class="descname">get_candidate_ver</code><span class="sig-paren">(</span><em>pkg: Package</em><span class="sig-paren">)</span> &rarr; Version<a class="headerlink" href="#apt_pkg.DepCache.get_candidate_ver" title="Permalink to this definition"></a></dt>
<dd><p>Return the candidate version for the package given by the parameter
<em>pkg</em> as a <a class="reference internal" href="#apt_pkg.Version" title="apt_pkg.Version"><code class="xref py py-class docutils literal"><span class="pre">Version</span></code></a> object. The default candidate for a
package is the version with the highest pin, although a different
one may be set using <a class="reference internal" href="#apt_pkg.DepCache.set_candidate_ver" title="apt_pkg.DepCache.set_candidate_ver"><code class="xref py py-meth docutils literal"><span class="pre">set_candidate_ver()</span></code></a>. If no candidate
can be found, return <code class="docutils literal"><span class="pre">None</span></code> instead.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.DepCache.init">
<code class="descname">init</code><span class="sig-paren">(</span><em>progress: apt.progress.base.OpProgress</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.DepCache.init" title="Permalink to this definition"></a></dt>
<dd><p>Initialize the DepCache. This is done automatically when the
cache is opened, but sometimes it may be useful to reinitialize
the DepCache. Like the constructor of <a class="reference internal" href="#apt_pkg.Cache" title="apt_pkg.Cache"><code class="xref py py-class docutils literal"><span class="pre">Cache</span></code></a>, this
function takes a single <a class="reference internal" href="apt.progress.base.html#apt.progress.base.OpProgress" title="apt.progress.base.OpProgress"><code class="xref py py-class docutils literal"><span class="pre">apt.progress.base.OpProgress</span></code></a>
object to display progress information.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.DepCache.read_pinfile">
<code class="descname">read_pinfile</code><span class="sig-paren">(</span><em>file: str</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.DepCache.read_pinfile" title="Permalink to this definition"></a></dt>
<dd><p>A proxy function which calls the method <a class="reference internal" href="#apt_pkg.Policy.read_pinfile" title="apt_pkg.Policy.read_pinfile"><code class="xref py py-meth docutils literal"><span class="pre">Policy.read_pinfile()</span></code></a> of
the <a class="reference internal" href="#apt_pkg.Policy" title="apt_pkg.Policy"><code class="xref py py-class docutils literal"><span class="pre">Policy</span></code></a> object used by this object. This method raises
a <code class="xref py py-exc docutils literal"><span class="pre">SystemError</span></code> exception if the file could not be parsed.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.DepCache.set_candidate_ver">
<code class="descname">set_candidate_ver</code><span class="sig-paren">(</span><em>pkg: Package</em>, <em>version: Version</em><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.DepCache.set_candidate_ver" title="Permalink to this definition"></a></dt>
<dd><p>Set the candidate version of the package given by the <a class="reference internal" href="#apt_pkg.Package" title="apt_pkg.Package"><code class="xref py py-class docutils literal"><span class="pre">Package</span></code></a>
object <em>pkg</em> to the version given by the <a class="reference internal" href="#apt_pkg.Version" title="apt_pkg.Version"><code class="xref py py-class docutils literal"><span class="pre">Version</span></code></a> object
<em>version</em> and return <code class="docutils literal"><span class="pre">True</span></code>. If odd things happen, this function
may raise a <code class="xref py py-exc docutils literal"><span class="pre">SystemError</span></code> exception, but this should not
happen in normal usage. See <a class="reference internal" href="#apt_pkg.DepCache.get_candidate_ver" title="apt_pkg.DepCache.get_candidate_ver"><code class="xref py py-meth docutils literal"><span class="pre">get_candidate_ver()</span></code></a> for a way
to retrieve the candidate version of a package.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.DepCache.upgrade">
<code class="descname">upgrade</code><span class="sig-paren">(</span><span class="optional">[</span><em>dist_upgrade=False</em><span class="optional">]</span><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.DepCache.upgrade" title="Permalink to this definition"></a></dt>
<dd><p>Mark the packages for upgrade under the same conditions
<strong class="program">apt-get</strong> does. If <em>dist_upgrade</em> is <code class="docutils literal"><span class="pre">True</span></code>, also
allow packages to be upgraded if they require installation/removal
of other packages; just like apt-get dist-upgrade.</p>
<p>Despite returning a boolean value, this raises <code class="xref py py-exc docutils literal"><span class="pre">SystemError</span></code> and
does not return <code class="docutils literal"><span class="pre">False</span></code> if an error occurred.</p>
</dd></dl>

<p>The following methods can mark a single package for installation,
removal, etc:</p>
<dl class="method">
<dt id="apt_pkg.DepCache.mark_auto">
<code class="descname">mark_auto</code><span class="sig-paren">(</span><em>pkg: Package</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.DepCache.mark_auto" title="Permalink to this definition"></a></dt>
<dd><p>Mark the <a class="reference internal" href="#apt_pkg.Package" title="apt_pkg.Package"><code class="xref py py-class docutils literal"><span class="pre">Package</span></code></a> <em>pkg</em> as automatically installed.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.DepCache.mark_keep">
<code class="descname">mark_keep</code><span class="sig-paren">(</span><em>pkg: Package</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.DepCache.mark_keep" title="Permalink to this definition"></a></dt>
<dd><p>Mark the <a class="reference internal" href="#apt_pkg.Package" title="apt_pkg.Package"><code class="xref py py-class docutils literal"><span class="pre">Package</span></code></a> <em>pkg</em> for keep.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.DepCache.mark_delete">
<code class="descname">mark_delete</code><span class="sig-paren">(</span><em>pkg: Package</em><span class="optional">[</span>, <em>purge</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.DepCache.mark_delete" title="Permalink to this definition"></a></dt>
<dd><p>Mark the <a class="reference internal" href="#apt_pkg.Package" title="apt_pkg.Package"><code class="xref py py-class docutils literal"><span class="pre">Package</span></code></a> <em>pkg</em> for delete. If <em>purge</em> is True,
the configuration files will be removed as well.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.DepCache.mark_install">
<code class="descname">mark_install</code><span class="sig-paren">(</span><em>pkg: Package</em><span class="optional">[</span>, <em>auto_inst=True</em><span class="optional">[</span>, <em>from_user=True</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.DepCache.mark_install" title="Permalink to this definition"></a></dt>
<dd><p>Mark the <a class="reference internal" href="#apt_pkg.Package" title="apt_pkg.Package"><code class="xref py py-class docutils literal"><span class="pre">Package</span></code></a> <em>pkg</em> for install, and, if <em>auto_inst</em>
is <code class="docutils literal"><span class="pre">True</span></code>, its dependencies as well. If <em>from_user</em> is <code class="docutils literal"><span class="pre">True</span></code>,
the package will <strong>not</strong> be marked as automatically installed.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.DepCache.set_reinstall">
<code class="descname">set_reinstall</code><span class="sig-paren">(</span><em>pkg: Package</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.DepCache.set_reinstall" title="Permalink to this definition"></a></dt>
<dd><p>Set if the <a class="reference internal" href="#apt_pkg.Package" title="apt_pkg.Package"><code class="xref py py-class docutils literal"><span class="pre">Package</span></code></a> <em>pkg</em> should be reinstalled.</p>
</dd></dl>

<p>The following methods can be used to check the state of a package:</p>
<dl class="method">
<dt id="apt_pkg.DepCache.is_auto_installed">
<code class="descname">is_auto_installed</code><span class="sig-paren">(</span><em>pkg: Package</em><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.DepCache.is_auto_installed" title="Permalink to this definition"></a></dt>
<dd><p>Return <code class="docutils literal"><span class="pre">True</span></code> if the package is automatically installed, that
is, as a dependency of another package.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.DepCache.is_garbage">
<code class="descname">is_garbage</code><span class="sig-paren">(</span><em>pkg: Package</em><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.DepCache.is_garbage" title="Permalink to this definition"></a></dt>
<dd><p>Return <code class="docutils literal"><span class="pre">True</span></code> if the package is garbage, that is, if it was
automatically installed and no longer referenced by other packages.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.DepCache.is_inst_broken">
<code class="descname">is_inst_broken</code><span class="sig-paren">(</span><em>pkg: Package</em><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.DepCache.is_inst_broken" title="Permalink to this definition"></a></dt>
<dd><p>Return <code class="docutils literal"><span class="pre">True</span></code> if the package is broken on the current install. This
takes changes which have not been marked not into account.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.DepCache.is_now_broken">
<code class="descname">is_now_broken</code><span class="sig-paren">(</span><em>pkg: Package</em><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.DepCache.is_now_broken" title="Permalink to this definition"></a></dt>
<dd><p>Return <code class="docutils literal"><span class="pre">True</span></code> if the package is now broken, that is, if the package
is broken if the marked changes are applied.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.DepCache.is_upgradable">
<code class="descname">is_upgradable</code><span class="sig-paren">(</span><em>pkg: Package</em><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.DepCache.is_upgradable" title="Permalink to this definition"></a></dt>
<dd><p>Return <code class="docutils literal"><span class="pre">True</span></code> if the package is upgradable, the package can then
be marked for upgrade by calling the method <a class="reference internal" href="#apt_pkg.DepCache.mark_install" title="apt_pkg.DepCache.mark_install"><code class="xref py py-meth docutils literal"><span class="pre">mark_install()</span></code></a>.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.DepCache.marked_delete">
<code class="descname">marked_delete</code><span class="sig-paren">(</span><em>pkg: Package</em><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.DepCache.marked_delete" title="Permalink to this definition"></a></dt>
<dd><p>Return <code class="docutils literal"><span class="pre">True</span></code> if the package is marked for delete.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.DepCache.marked_downgrade">
<code class="descname">marked_downgrade</code><span class="sig-paren">(</span><em>pkg: Package</em><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.DepCache.marked_downgrade" title="Permalink to this definition"></a></dt>
<dd><p>Return <code class="docutils literal"><span class="pre">True</span></code> if the package should be downgraded.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.DepCache.marked_install">
<code class="descname">marked_install</code><span class="sig-paren">(</span><em>pkg: Package</em><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.DepCache.marked_install" title="Permalink to this definition"></a></dt>
<dd><p>Return <code class="docutils literal"><span class="pre">True</span></code> if the package is marked for install.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.DepCache.marked_keep">
<code class="descname">marked_keep</code><span class="sig-paren">(</span><em>pkg: Package</em><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.DepCache.marked_keep" title="Permalink to this definition"></a></dt>
<dd><p>Return <code class="docutils literal"><span class="pre">True</span></code> if the package is marked for keep.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.DepCache.marked_reinstall">
<code class="descname">marked_reinstall</code><span class="sig-paren">(</span><em>pkg: Package</em><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.DepCache.marked_reinstall" title="Permalink to this definition"></a></dt>
<dd><p>Return <code class="docutils literal"><span class="pre">True</span></code> if the package should be reinstalled.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.DepCache.marked_upgrade">
<code class="descname">marked_upgrade</code><span class="sig-paren">(</span><em>pkg: Package</em><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.DepCache.marked_upgrade" title="Permalink to this definition"></a></dt>
<dd><p>Return <code class="docutils literal"><span class="pre">True</span></code> if the package is marked for upgrade.</p>
</dd></dl>

<p>DepCache objects also provide several attributes containing information
on the marked changes:</p>
<dl class="attribute">
<dt id="apt_pkg.DepCache.keep_count">
<code class="descname">keep_count</code><a class="headerlink" href="#apt_pkg.DepCache.keep_count" title="Permalink to this definition"></a></dt>
<dd><p>Integer, number of packages marked as keep</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.DepCache.inst_count">
<code class="descname">inst_count</code><a class="headerlink" href="#apt_pkg.DepCache.inst_count" title="Permalink to this definition"></a></dt>
<dd><p>Integer, number of packages marked for installation.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.DepCache.del_count">
<code class="descname">del_count</code><a class="headerlink" href="#apt_pkg.DepCache.del_count" title="Permalink to this definition"></a></dt>
<dd><p>Number of packages which should be removed.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.DepCache.broken_count">
<code class="descname">broken_count</code><a class="headerlink" href="#apt_pkg.DepCache.broken_count" title="Permalink to this definition"></a></dt>
<dd><p>Number of packages which are broken.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.DepCache.usr_size">
<code class="descname">usr_size</code><a class="headerlink" href="#apt_pkg.DepCache.usr_size" title="Permalink to this definition"></a></dt>
<dd><p>The size required for the changes on the filesystem. If you install
packages, this is positive, if you remove them its negative.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.DepCache.deb_size">
<code class="descname">deb_size</code><a class="headerlink" href="#apt_pkg.DepCache.deb_size" title="Permalink to this definition"></a></dt>
<dd><p>The size of the packages which are needed for the changes to be
applied.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.DepCache.policy">
<code class="descname">policy</code><a class="headerlink" href="#apt_pkg.DepCache.policy" title="Permalink to this definition"></a></dt>
<dd><p>The underlying <a class="reference internal" href="#apt_pkg.Policy" title="apt_pkg.Policy"><code class="xref py py-class docutils literal"><span class="pre">Policy</span></code></a> object used by the <a class="reference internal" href="#apt_pkg.DepCache" title="apt_pkg.DepCache"><code class="xref py py-class docutils literal"><span class="pre">DepCache</span></code></a> to
select candidate versions.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="installing-with-packagemanager">
<h3>Installing with <a class="reference internal" href="#apt_pkg.PackageManager" title="apt_pkg.PackageManager"><code class="xref py py-class docutils literal"><span class="pre">PackageManager</span></code></a><a class="headerlink" href="#installing-with-packagemanager" title="Permalink to this headline"></a></h3>
<dl class="class">
<dt id="apt_pkg.PackageManager">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">PackageManager</code><span class="sig-paren">(</span><em>depcache</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.PackageManager" title="Permalink to this definition"></a></dt>
<dd><p>Abstraction of a package manager. This object takes care of retrieving
packages, ordering the installation, and calling the package manager to
do the actual installation.</p>
<dl class="method">
<dt id="apt_pkg.PackageManager.get_archives">
<code class="descname">get_archives</code><span class="sig-paren">(</span><em>fetcher</em>, <em>list</em>, <em>records</em><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.PackageManager.get_archives" title="Permalink to this definition"></a></dt>
<dd><p>Add all packages marked for installation (or upgrade, anything
which needs a download) to the <a class="reference internal" href="#apt_pkg.Acquire" title="apt_pkg.Acquire"><code class="xref py py-class docutils literal"><span class="pre">Acquire</span></code></a> object referenced
by <em>fetcher</em>.</p>
<p>The parameter <em>list</em> specifies a <a class="reference internal" href="#apt_pkg.SourceList" title="apt_pkg.SourceList"><code class="xref py py-class docutils literal"><span class="pre">SourceList</span></code></a> object which
is used to retrieve the information about the archive URI for the
packages which will be fetched.</p>
<p>The parameter <em>records</em> takes a <a class="reference internal" href="#apt_pkg.PackageRecords" title="apt_pkg.PackageRecords"><code class="xref py py-class docutils literal"><span class="pre">PackageRecords</span></code></a> object which
will be used to look up the file name of the package.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.PackageManager.do_install">
<code class="descname">do_install</code><span class="sig-paren">(</span><em>status_fd: int</em><span class="sig-paren">)</span> &rarr; int<a class="headerlink" href="#apt_pkg.PackageManager.do_install" title="Permalink to this definition"></a></dt>
<dd><p>Install the packages and return one of the class constants
<a class="reference internal" href="#apt_pkg.PackageManager.RESULT_COMPLETED" title="apt_pkg.PackageManager.RESULT_COMPLETED"><code class="xref py py-attr docutils literal"><span class="pre">RESULT_COMPLETED</span></code></a>, <a class="reference internal" href="#apt_pkg.PackageManager.RESULT_FAILED" title="apt_pkg.PackageManager.RESULT_FAILED"><code class="xref py py-attr docutils literal"><span class="pre">RESULT_FAILED</span></code></a>,
<a class="reference internal" href="#apt_pkg.PackageManager.RESULT_INCOMPLETE" title="apt_pkg.PackageManager.RESULT_INCOMPLETE"><code class="xref py py-attr docutils literal"><span class="pre">RESULT_INCOMPLETE</span></code></a>. The argument <em>status_fd</em> can be used
to specify a file descriptor that APT will write status information
on (see README.progress-reporting in the apt source code for
information on what will be written there).</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.PackageManager.fix_missing">
<code class="descname">fix_missing</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.PackageManager.fix_missing" title="Permalink to this definition"></a></dt>
<dd><p>Fix the installation if a package could not be downloaded.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.PackageManager.RESULT_COMPLETED">
<code class="descname">RESULT_COMPLETED</code><a class="headerlink" href="#apt_pkg.PackageManager.RESULT_COMPLETED" title="Permalink to this definition"></a></dt>
<dd><p>A constant for checking whether the result of the call to
<a class="reference internal" href="#apt_pkg.PackageManager.do_install" title="apt_pkg.PackageManager.do_install"><code class="xref py py-meth docutils literal"><span class="pre">do_install()</span></code></a> is &#8216;failed&#8217;.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.PackageManager.RESULT_FAILED">
<code class="descname">RESULT_FAILED</code><a class="headerlink" href="#apt_pkg.PackageManager.RESULT_FAILED" title="Permalink to this definition"></a></dt>
<dd><p>A constant for checking whether the result of the call to
<a class="reference internal" href="#apt_pkg.PackageManager.do_install" title="apt_pkg.PackageManager.do_install"><code class="xref py py-meth docutils literal"><span class="pre">do_install()</span></code></a> is &#8216;failed&#8217;.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.PackageManager.RESULT_INCOMPLETE">
<code class="descname">RESULT_INCOMPLETE</code><a class="headerlink" href="#apt_pkg.PackageManager.RESULT_INCOMPLETE" title="Permalink to this definition"></a></dt>
<dd><p>A constant for checking whether the result of the call to
<a class="reference internal" href="#apt_pkg.PackageManager.do_install" title="apt_pkg.PackageManager.do_install"><code class="xref py py-meth docutils literal"><span class="pre">do_install()</span></code></a> is &#8216;incomplete&#8217;.</p>
</dd></dl>

<p>All instances of this class also support the following methods:</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This methods are provided mainly for subclassing purposes
and should not be used in most programs. This class is a
subclass of an internal <code class="xref py py-class docutils literal"><span class="pre">_PackageManager</span></code> which does
not provide that methods. As the public C++ API creates such
an object without those methods, you should not rely on those
methods to be available unless you used the constructor of
<a class="reference internal" href="#apt_pkg.PackageManager" title="apt_pkg.PackageManager"><code class="xref py py-class docutils literal"><span class="pre">PackageManager</span></code></a> to create the object.</p>
</div>
<dl class="method">
<dt id="apt_pkg.PackageManager.configure">
<code class="descname">configure</code><span class="sig-paren">(</span><em>pkg: Package</em><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.PackageManager.configure" title="Permalink to this definition"></a></dt>
<dd><p>Notify the package manager that the <a class="reference internal" href="#apt_pkg.Package" title="apt_pkg.Package"><code class="xref py py-class docutils literal"><span class="pre">Package</span></code></a> given
by <em>pkg</em> is to be configured. Must return a <code class="docutils literal"><span class="pre">True</span></code> value
or <code class="docutils literal"><span class="pre">None</span></code> to continue, or a value which is <code class="docutils literal"><span class="pre">False</span></code> if
evaluated as boolean to abort.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.8.0.</span></p>
</div>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.PackageManager.install">
<code class="descname">install</code><span class="sig-paren">(</span><em>pkg: Package</em>, <em>filename: str</em><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.PackageManager.install" title="Permalink to this definition"></a></dt>
<dd><p>Notify the package manager that the <a class="reference internal" href="#apt_pkg.Package" title="apt_pkg.Package"><code class="xref py py-class docutils literal"><span class="pre">Package</span></code></a> given
by <em>pkg</em> is to be installed from the .deb located at
<em>filename</em>. Must return a <code class="docutils literal"><span class="pre">True</span></code> value or <code class="docutils literal"><span class="pre">None</span></code> to
continue, or a value which is <code class="docutils literal"><span class="pre">False</span></code> if evaluated as
boolean to abort.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.8.0.</span></p>
</div>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.PackageManager.remove">
<code class="descname">remove</code><span class="sig-paren">(</span><em>pkg: Package</em>, <em>purge: bool</em><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.PackageManager.remove" title="Permalink to this definition"></a></dt>
<dd><p>Notify the package manager that the <a class="reference internal" href="#apt_pkg.Package" title="apt_pkg.Package"><code class="xref py py-class docutils literal"><span class="pre">Package</span></code></a> given
by <em>pkg</em> is to be removed. If <em>purge</em> is <code class="docutils literal"><span class="pre">True</span></code>, the package
shall be purged. Must return a <code class="docutils literal"><span class="pre">True</span></code> value or <code class="docutils literal"><span class="pre">None</span></code> to
continue, or a value which is <code class="docutils literal"><span class="pre">False</span></code> if evaluated as boolean
to abort.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.8.0.</span></p>
</div>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.PackageManager.go">
<code class="descname">go</code><span class="sig-paren">(</span><em>status_fd: int</em><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.PackageManager.go" title="Permalink to this definition"></a></dt>
<dd><p>Start dpkg, writing status information to the file descriptor
given by <em>status_fd</em>. Must return a <code class="docutils literal"><span class="pre">True</span></code> value or <code class="docutils literal"><span class="pre">None</span></code> to
continue, or a value which is <code class="docutils literal"><span class="pre">False</span></code> if evaluated as boolean
to abort.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.8.0.</span></p>
</div>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.PackageManager.reset">
<code class="descname">reset</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.PackageManager.reset" title="Permalink to this definition"></a></dt>
<dd><p>Reset the package manager for a new round.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.8.0.</span></p>
</div>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="installation-ordering-with-orderlist">
<h3>Installation ordering with <a class="reference internal" href="#apt_pkg.OrderList" title="apt_pkg.OrderList"><code class="xref py py-class docutils literal"><span class="pre">OrderList</span></code></a><a class="headerlink" href="#installation-ordering-with-orderlist" title="Permalink to this headline"></a></h3>
<dl class="class">
<dt id="apt_pkg.OrderList">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">OrderList</code><span class="sig-paren">(</span><em>depcache: DepCache</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.OrderList" title="Permalink to this definition"></a></dt>
<dd><p>Represent a <code class="xref c c-type docutils literal"><span class="pre">pkgOrderList</span></code>, used for installation
ordering. This class provides several methods and attributes,
is complicated and should not be used by normal programs.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.8.0.</span></p>
</div>
<p>This class is a sequence and supports the following operations:</p>
<dl class="describe">
<dt>
<code class="descname">list[index]</code></dt>
<dd><p>Get the package at the given index in the list. Negative
index is supported.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="descname">len(list)</code></dt>
<dd><p>The length of the list.</p>
</dd></dl>

<p>It also supports the append() method from <code class="xref py py-class docutils literal"><span class="pre">list</span></code>:</p>
<dl class="method">
<dt id="apt_pkg.OrderList.append">
<code class="descname">append</code><span class="sig-paren">(</span><em>pkg: Package</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.OrderList.append" title="Permalink to this definition"></a></dt>
<dd><p>Append a new package to the end of the list. Please note that
you may not append a package twice, as only as much packages
as in the cache can be added.</p>
</dd></dl>

<p>The class also defines several specific attributes and methods,
to be described hereinafter.</p>
<dl class="method">
<dt id="apt_pkg.OrderList.score">
<code class="descname">score</code><span class="sig-paren">(</span><em>pkg: Package</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.OrderList.score" title="Permalink to this definition"></a></dt>
<dd><p>Return the score of the package. Packages are basically
ordered by descending score.</p>
</dd></dl>

<p>This class allows flags to be set on packages. Those flags are:</p>
<dl class="attribute">
<dt id="apt_pkg.OrderList.FLAG_ADDED">
<code class="descname">FLAG_ADDED</code><a class="headerlink" href="#apt_pkg.OrderList.FLAG_ADDED" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="apt_pkg.OrderList.FLAG_ADD_PENDING">
<code class="descname">FLAG_ADD_PENDING</code><a class="headerlink" href="#apt_pkg.OrderList.FLAG_ADD_PENDING" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="apt_pkg.OrderList.FLAG_IMMEDIATE">
<code class="descname">FLAG_IMMEDIATE</code><a class="headerlink" href="#apt_pkg.OrderList.FLAG_IMMEDIATE" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="apt_pkg.OrderList.FLAG_LOOP">
<code class="descname">FLAG_LOOP</code><a class="headerlink" href="#apt_pkg.OrderList.FLAG_LOOP" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="apt_pkg.OrderList.FLAG_UNPACKED">
<code class="descname">FLAG_UNPACKED</code><a class="headerlink" href="#apt_pkg.OrderList.FLAG_UNPACKED" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="apt_pkg.OrderList.FLAG_CONFIGURED">
<code class="descname">FLAG_CONFIGURED</code><a class="headerlink" href="#apt_pkg.OrderList.FLAG_CONFIGURED" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="apt_pkg.OrderList.FLAG_REMOVED">
<code class="descname">FLAG_REMOVED</code><a class="headerlink" href="#apt_pkg.OrderList.FLAG_REMOVED" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="apt_pkg.OrderList.FLAG_STATES_MASK">
<code class="descname">FLAG_STATES_MASK</code><a class="headerlink" href="#apt_pkg.OrderList.FLAG_STATES_MASK" title="Permalink to this definition"></a></dt>
<dd><p>Same as <code class="docutils literal"><span class="pre">FLAG_UNPACKED</span> <span class="pre">|</span> <span class="pre">FLAG_CONFIGURED</span> <span class="pre">|</span> <span class="pre">FLAG_REMOVED</span></code></p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.OrderList.FLAG_IN_LIST">
<code class="descname">FLAG_IN_LIST</code><a class="headerlink" href="#apt_pkg.OrderList.FLAG_IN_LIST" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="apt_pkg.OrderList.FLAG_AFTER">
<code class="descname">FLAG_AFTER</code><a class="headerlink" href="#apt_pkg.OrderList.FLAG_AFTER" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<p>The methods to work with those flags are:</p>
<dl class="method">
<dt id="apt_pkg.OrderList.flag">
<code class="descname">flag</code><span class="sig-paren">(</span><em>pkg: Package</em>, <em>flag: int</em><span class="optional">[</span>, <em>unset_flags: int</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.OrderList.flag" title="Permalink to this definition"></a></dt>
<dd><p>Flag a package. Sets the flags given in <em>flag</em> and unsets
any flags given in <em>unset_flags</em>.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.OrderList.is_flag">
<code class="descname">is_flag</code><span class="sig-paren">(</span><em>pkg: Package</em>, <em>flag: int</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.OrderList.is_flag" title="Permalink to this definition"></a></dt>
<dd><p>Check whether the flags in <em>flag</em> are set for the package.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.OrderList.wipe_flags">
<code class="descname">wipe_flags</code><span class="sig-paren">(</span><em>flags: int</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.OrderList.wipe_flags" title="Permalink to this definition"></a></dt>
<dd><p>Remove the flags in <em>flags</em> from all packages.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.OrderList.is_missing">
<code class="descname">is_missing</code><span class="sig-paren">(</span><em>pkg: Package</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.OrderList.is_missing" title="Permalink to this definition"></a></dt>
<dd><p>Check if the package is missing (not really usable right now)</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.OrderList.is_now">
<code class="descname">is_now</code><span class="sig-paren">(</span><em>pkg: Package</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.OrderList.is_now" title="Permalink to this definition"></a></dt>
<dd><p>Check if the package is flagged for any state but removal.</p>
</dd></dl>

<p>The following methods for ordering are provided:</p>
<dl class="method">
<dt id="apt_pkg.OrderList.order_critical">
<code class="descname">order_critical</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.OrderList.order_critical" title="Permalink to this definition"></a></dt>
<dd><p>Order the packages for critical unpacking; that is, only
respect pre-dependencies.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.OrderList.order_unpack">
<code class="descname">order_unpack</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.OrderList.order_unpack" title="Permalink to this definition"></a></dt>
<dd><p>Order the packages for unpacking, repecting Pre-Depends and
Conflicts.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.OrderList.order_configure">
<code class="descname">order_configure</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.OrderList.order_configure" title="Permalink to this definition"></a></dt>
<dd><p>Order the packages for configuration, respecting Depends.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="improve-performance-with-actiongroup">
<h3>Improve performance with <a class="reference internal" href="#apt_pkg.ActionGroup" title="apt_pkg.ActionGroup"><code class="xref py py-class docutils literal"><span class="pre">ActionGroup</span></code></a><a class="headerlink" href="#improve-performance-with-actiongroup" title="Permalink to this headline"></a></h3>
<dl class="class">
<dt id="apt_pkg.ActionGroup">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">ActionGroup</code><span class="sig-paren">(</span><em>depcache</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.ActionGroup" title="Permalink to this definition"></a></dt>
<dd><p>Create a new <a class="reference internal" href="#apt_pkg.ActionGroup" title="apt_pkg.ActionGroup"><code class="xref py py-class docutils literal"><span class="pre">ActionGroup()</span></code></a> object for the <a class="reference internal" href="#apt_pkg.DepCache" title="apt_pkg.DepCache"><code class="xref py py-class docutils literal"><span class="pre">DepCache</span></code></a> object
given by the parameter <em>depcache</em>.</p>
<p><a class="reference internal" href="#apt_pkg.ActionGroup" title="apt_pkg.ActionGroup"><code class="xref py py-class docutils literal"><span class="pre">ActionGroup()</span></code></a> objects make operations on the cache faster by
delaying certain cleanup operations until the action group is released.</p>
<p>An action group is also a context manager and therefore supports the
<code class="xref std std-keyword docutils literal"><span class="pre">with</span></code> statement. But because it becomes active as soon as it
is created, you should not create an ActionGroup() object before entering
the with statement. Thus, you should always use the following form:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">with</span> <span class="n">apt_pkg</span><span class="o">.</span><span class="n">ActionGroup</span><span class="p">(</span><span class="n">depcache</span><span class="p">):</span>
    <span class="o">...</span>
</pre></div>
</div>
<p>For code which has to run on Python versions prior to 2.5, you can also
use the traditional way:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">actiongroup</span> <span class="o">=</span> <span class="n">apt_pkg</span><span class="o">.</span><span class="n">ActionGroup</span><span class="p">(</span><span class="n">depcache</span><span class="p">)</span>
<span class="o">...</span>
<span class="n">actiongroup</span><span class="o">.</span><span class="n">release</span><span class="p">()</span>
</pre></div>
</div>
<p>In addition to the methods required to implement the context
manager interface, <a class="reference internal" href="#apt_pkg.ActionGroup" title="apt_pkg.ActionGroup"><code class="xref py py-class docutils literal"><span class="pre">ActionGroup</span></code></a> objects provide the
following method:</p>
<dl class="method">
<dt id="apt_pkg.ActionGroup.release">
<code class="descname">release</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.ActionGroup.release" title="Permalink to this definition"></a></dt>
<dd><p>Release the ActionGroup. This will reactive the collection of package
garbage.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="resolving-dependencies-with-problemresolver">
<h3>Resolving Dependencies with <a class="reference internal" href="#apt_pkg.ProblemResolver" title="apt_pkg.ProblemResolver"><code class="xref py py-class docutils literal"><span class="pre">ProblemResolver</span></code></a><a class="headerlink" href="#resolving-dependencies-with-problemresolver" title="Permalink to this headline"></a></h3>
<dl class="class">
<dt id="apt_pkg.ProblemResolver">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">ProblemResolver</code><span class="sig-paren">(</span><em>depcache: DepCache</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.ProblemResolver" title="Permalink to this definition"></a></dt>
<dd><p>ProblemResolver objects take care of resolving problems with
dependencies. They mark packages for installation/removal and
try to satisfy all dependencies. The constructor takes a single
argument of the type <a class="reference internal" href="#apt_pkg.DepCache" title="apt_pkg.DepCache"><code class="xref py py-class docutils literal"><span class="pre">apt_pkg.DepCache</span></code></a> to determine the
cache that shall be manipulated in order to resolve the problems.</p>
<dl class="method">
<dt id="apt_pkg.ProblemResolver.clear">
<code class="descname">clear</code><span class="sig-paren">(</span><em>pkg: Package</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.ProblemResolver.clear" title="Permalink to this definition"></a></dt>
<dd><p>Revert the action of calling <a class="reference internal" href="#apt_pkg.ProblemResolver.protect" title="apt_pkg.ProblemResolver.protect"><code class="xref py py-meth docutils literal"><span class="pre">protect()</span></code></a> or <a class="reference internal" href="#apt_pkg.ProblemResolver.remove" title="apt_pkg.ProblemResolver.remove"><code class="xref py py-meth docutils literal"><span class="pre">remove()</span></code></a> on
a package, resetting it to the default state.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.ProblemResolver.install_protect">
<code class="descname">install_protect</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.ProblemResolver.install_protect" title="Permalink to this definition"></a></dt>
<dd><p>Mark all protected packages for installation.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.ProblemResolver.protect">
<code class="descname">protect</code><span class="sig-paren">(</span><em>pkg: Package</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.ProblemResolver.protect" title="Permalink to this definition"></a></dt>
<dd><p>Mark the package given by <em>pkg</em> as protected; that is, its state
will not be changed.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.ProblemResolver.remove">
<code class="descname">remove</code><span class="sig-paren">(</span><em>pkg: Package</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.ProblemResolver.remove" title="Permalink to this definition"></a></dt>
<dd><p>Mark the package given by <em>pkg</em> for removal in the resolver.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.ProblemResolver.resolve">
<code class="descname">resolve</code><span class="sig-paren">(</span><span class="optional">[</span><em>fix_broken: bool = True</em><span class="optional">]</span><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.ProblemResolver.resolve" title="Permalink to this definition"></a></dt>
<dd><p>Try to intelligently resolve problems by installing and removing
packages. If <em>fix_broken</em> is <code class="docutils literal"><span class="pre">True</span></code>, apt will try to repair broken
dependencies of installed packages.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.ProblemResolver.resolve_by_keep">
<code class="descname">resolve_by_keep</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.ProblemResolver.resolve_by_keep" title="Permalink to this definition"></a></dt>
<dd><p>Try to resolve the problems without installing or removing packages.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="group-of-packages-with-the-same-name">
<h3><a class="reference internal" href="#apt_pkg.Group" title="apt_pkg.Group"><code class="xref py py-class docutils literal"><span class="pre">Group</span></code></a> of packages with the same name<a class="headerlink" href="#group-of-packages-with-the-same-name" title="Permalink to this headline"></a></h3>
<dl class="class">
<dt id="apt_pkg.Group">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">Group</code><span class="sig-paren">(</span><em>cache: Cache</em>, <em>name: str</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.Group" title="Permalink to this definition"></a></dt>
<dd><div class="versionadded">
<p><span class="versionmodified">New in version 0.8.0.</span></p>
</div>
<p>A collection of packages in which all packages have the same name. Groups
are used in multi-arch environments, where two or more packages have the
same name, but different architectures.</p>
<p>Group objects provide the following parts for sequential access:</p>
<dl class="describe">
<dt>
<code class="descname">group[index]</code></dt>
<dd><p>Get the package at the given <strong>index</strong> in the group.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Groups are internally implemented using a linked list. The object
keeps a pointer to the current object and the first object, so
access to the first element, or accesses in order have a
complexity of O(1). Random-access complexity is ranges from
O(1) to O(n).</p>
</div>
</dd></dl>

<p>Group objects also provide special methods to find single packages:</p>
<dl class="method">
<dt id="apt_pkg.Group.find_package">
<code class="descname">find_package</code><span class="sig-paren">(</span><em>architecture: str</em><span class="sig-paren">)</span> &rarr; Package<a class="headerlink" href="#apt_pkg.Group.find_package" title="Permalink to this definition"></a></dt>
<dd><p>Find a package with the groups name and the architecture given
in the argument <em>architecture</em>. If no such package exists, return
<code class="docutils literal"><span class="pre">None</span></code>.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.Group.find_preferred_package">
<code class="descname">find_preferred_package</code><span class="sig-paren">(</span><em>prefer_nonvirtual: bool = True</em><span class="sig-paren">)</span> &rarr; Package<a class="headerlink" href="#apt_pkg.Group.find_preferred_package" title="Permalink to this definition"></a></dt>
<dd><p>Find the preferred package. This is the package of the native
architecture (specified in <code class="docutils literal"><span class="pre">APT::Architecture</span></code>) if available,
or the package from the first foreign architecture. If no package
could be found, return <code class="docutils literal"><span class="pre">None</span></code></p>
<p>If <strong>prefer_nonvirtual</strong> is <code class="docutils literal"><span class="pre">True</span></code>, the preferred package
will be a non-virtual package, if one exists.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="package-information">
<h3><a class="reference internal" href="#apt_pkg.Package" title="apt_pkg.Package"><code class="xref py py-class docutils literal"><span class="pre">Package</span></code></a> information<a class="headerlink" href="#package-information" title="Permalink to this headline"></a></h3>
<dl class="class">
<dt id="apt_pkg.Package">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">Package</code><a class="headerlink" href="#apt_pkg.Package" title="Permalink to this definition"></a></dt>
<dd><p>Represent a package. A package is uniquely identified by its name and
architecture and each package can have zero or more versions which can be
accessed via the <a class="reference internal" href="#apt_pkg.version_list" title="apt_pkg.version_list"><code class="xref py py-attr docutils literal"><span class="pre">version_list</span></code></a> property. Packages can be
installed and removed by a <a class="reference internal" href="#apt_pkg.DepCache" title="apt_pkg.DepCache"><code class="xref py py-class docutils literal"><span class="pre">DepCache</span></code></a> object.</p>
<blockquote>
<div><p>Attributes:</p>
<dl class="attribute">
<dt id="apt_pkg.Package.current_ver">
<code class="descname">current_ver</code><a class="headerlink" href="#apt_pkg.Package.current_ver" title="Permalink to this definition"></a></dt>
<dd><p>The version currently installed as a <a class="reference internal" href="#apt_pkg.Version" title="apt_pkg.Version"><code class="xref py py-class docutils literal"><span class="pre">Version</span></code></a> object, or None
if the package is not installed.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.Package.get_fullname">
<code class="descname">get_fullname</code><span class="sig-paren">(</span><span class="optional">[</span><em>pretty: bool = False</em><span class="optional">]</span><span class="sig-paren">)</span> &rarr; str<a class="headerlink" href="#apt_pkg.Package.get_fullname" title="Permalink to this definition"></a></dt>
<dd><p>Get the full name of the package, including the architecture. If
<em>pretty</em> is <code class="docutils literal"><span class="pre">True</span></code>, the architecture is omitted for native packages,
that is, an amd64 &#8220;apt&#8221; package on an amd64 system would give &#8220;apt&#8221;.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.7.100.3.</span></p>
</div>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Package.has_provides">
<code class="descname">has_provides</code><a class="headerlink" href="#apt_pkg.Package.has_provides" title="Permalink to this definition"></a></dt>
<dd><p>A boolean value determining whether the list available via the
attribute <a class="reference internal" href="#apt_pkg.Package.provides_list" title="apt_pkg.Package.provides_list"><code class="xref py py-attr docutils literal"><span class="pre">provides_list</span></code></a> has at least one element. This
value may be used in combination with <a class="reference internal" href="#apt_pkg.Package.has_versions" title="apt_pkg.Package.has_versions"><code class="xref py py-attr docutils literal"><span class="pre">has_versions</span></code></a> to
check whether a package is virtual; that is, it has no versions
and is provided at least once:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">pkg</span><span class="o">.</span><span class="n">has_provides</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">pkg</span><span class="o">.</span><span class="n">has_versions</span>
</pre></div>
</div>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Package.has_versions">
<code class="descname">has_versions</code><a class="headerlink" href="#apt_pkg.Package.has_versions" title="Permalink to this definition"></a></dt>
<dd><p>A boolean value determining whether the list available via the
attribute <a class="reference internal" href="#apt_pkg.version_list" title="apt_pkg.version_list"><code class="xref py py-attr docutils literal"><span class="pre">version_list</span></code></a> has at least one element. This
value may be used in combination with <a class="reference internal" href="#apt_pkg.Package.has_provides" title="apt_pkg.Package.has_provides"><code class="xref py py-attr docutils literal"><span class="pre">has_provides</span></code></a> to
check whether a package is virtual; that is, it has no versions
and is provided at least once:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">pkg</span><span class="o">.</span><span class="n">has_provides</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">pkg</span><span class="o">.</span><span class="n">has_versions</span>
</pre></div>
</div>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Package.id">
<code class="descname">id</code><a class="headerlink" href="#apt_pkg.Package.id" title="Permalink to this definition"></a></dt>
<dd><p>The ID of the package. This can be used to store information about
the package. The ID is an int value.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Package.name">
<code class="descname">name</code><a class="headerlink" href="#apt_pkg.Package.name" title="Permalink to this definition"></a></dt>
<dd><p>This is the name of the package.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Package.provides_list">
<code class="descname">provides_list</code><a class="headerlink" href="#apt_pkg.Package.provides_list" title="Permalink to this definition"></a></dt>
<dd><p>A list of all package versions providing this package. Each element
of the list is a triplet, where the first element is the name of the
provided package, the second element the provided version (empty
string), and the third element the version providing this package
as a <a class="reference internal" href="#apt_pkg.Version" title="apt_pkg.Version"><code class="xref py py-class docutils literal"><span class="pre">Version</span></code></a> object.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Package.rev_depends_list">
<code class="descname">rev_depends_list</code><a class="headerlink" href="#apt_pkg.Package.rev_depends_list" title="Permalink to this definition"></a></dt>
<dd><p>An iterator of <a class="reference internal" href="#apt_pkg.Dependency" title="apt_pkg.Dependency"><code class="xref py py-class docutils literal"><span class="pre">Dependency</span></code></a> objects for dependencies on this
package. The returned iterator is implemented by the class
<a class="reference internal" href="#apt_pkg.Package.DependencyList" title="apt_pkg.Package.DependencyList"><code class="xref py py-class docutils literal"><span class="pre">DependencyList</span></code></a>:</p>
<dl class="class">
<dt id="apt_pkg.Package.DependencyList">
<em class="property">class </em><code class="descname">DependencyList</code><a class="headerlink" href="#apt_pkg.Package.DependencyList" title="Permalink to this definition"></a></dt>
<dd><p>A simple list-like type for representing multiple dependency
objects in an efficient manner; without having to generate
all Dependency objects in advance.</p>
<dl class="describe">
<dt>
<code class="descname">list[index]</code></dt>
<dd><p>Return the item at the position <em>index</em> in the list.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.Package.DependencyList.__len__">
<code class="descname">__len__</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.Package.DependencyList.__len__" title="Permalink to this definition"></a></dt>
<dd><p>The length of the list. This method should not be used
irectly, instead Python&#8217;s built-in function <code class="xref py py-func docutils literal"><span class="pre">len()</span></code>
should be used.</p>
</dd></dl>

</dd></dl>

</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.section">
<code class="descclassname">apt_pkg.</code><code class="descname">section</code><a class="headerlink" href="#apt_pkg.section" title="Permalink to this definition"></a></dt>
<dd><p>The section of the package, as specified in the record. The list of
possible sections is defined in the Policy. This is a string.</p>
<div class="deprecated">
<p><span class="versionmodified">Deprecated since version 1.0: </span>A package can have multiple versions with different sections, so
the section information should be accessed from the version class.</p>
</div>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.version_list">
<code class="descclassname">apt_pkg.</code><code class="descname">version_list</code><a class="headerlink" href="#apt_pkg.version_list" title="Permalink to this definition"></a></dt>
<dd><p>A list of <a class="reference internal" href="#apt_pkg.Version" title="apt_pkg.Version"><code class="xref py py-class docutils literal"><span class="pre">Version</span></code></a> objects for all versions of this package
available in the cache.</p>
</dd></dl>

<p><strong>States</strong>:</p>
<dl class="attribute">
<dt id="apt_pkg.selected_state">
<code class="descclassname">apt_pkg.</code><code class="descname">selected_state</code><a class="headerlink" href="#apt_pkg.selected_state" title="Permalink to this definition"></a></dt>
<dd><p>The state we want it to be, ie. if you mark a package for installation,
this is <a class="reference internal" href="#apt_pkg.SELSTATE_INSTALL" title="apt_pkg.SELSTATE_INSTALL"><code class="xref py py-attr docutils literal"><span class="pre">apt_pkg.SELSTATE_INSTALL</span></code></a>.</p>
<p>See <a class="reference internal" href="#selstates"><span>Package selection states</span></a> for a list of available states.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.inst_state">
<code class="descclassname">apt_pkg.</code><code class="descname">inst_state</code><a class="headerlink" href="#apt_pkg.inst_state" title="Permalink to this definition"></a></dt>
<dd><p>The state the currently installed version is in. This is normally
<a class="reference internal" href="#apt_pkg.INSTSTATE_OK" title="apt_pkg.INSTSTATE_OK"><code class="xref py py-attr docutils literal"><span class="pre">apt_pkg.INSTSTATE_OK</span></code></a>, unless the installation failed.</p>
<p>See <a class="reference internal" href="#inststates"><span>Installed states</span></a> for a list of available states.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.current_state">
<code class="descclassname">apt_pkg.</code><code class="descname">current_state</code><a class="headerlink" href="#apt_pkg.current_state" title="Permalink to this definition"></a></dt>
<dd><p>The current state of the package (not installed, unpacked, installed,
etc). See <a class="reference internal" href="#curstates"><span>Package States</span></a> for a list of available states.</p>
</dd></dl>

<p><strong>Flags</strong>:</p>
<dl class="attribute">
<dt id="apt_pkg.essential">
<code class="descclassname">apt_pkg.</code><code class="descname">essential</code><a class="headerlink" href="#apt_pkg.essential" title="Permalink to this definition"></a></dt>
<dd><p>Whether the package has the &#8216;Essential&#8217; flag set; that is,
whether it has a field &#8216;Essential: yes&#8217; in its record.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.important">
<code class="descclassname">apt_pkg.</code><code class="descname">important</code><a class="headerlink" href="#apt_pkg.important" title="Permalink to this definition"></a></dt>
<dd><p>Whether the package has the (obsolete) &#8216;Important&#8217; flag set; that is,
whether it has a field &#8216;Important: yes&#8217; in its record.</p>
</dd></dl>

</div></blockquote>
</dd></dl>

<div class="section" id="example">
<h4>Example:<a class="headerlink" href="#example" title="Permalink to this headline"></a></h4>
<div class="highlight-python"><div class="highlight"><pre><span class="c">#!/usr/bin/python</span>
<span class="sd">&quot;&quot;&quot;Example for packages. Print all essential and important packages&quot;&quot;&quot;</span>

<span class="kn">import</span> <span class="nn">apt_pkg</span>


<span class="k">def</span> <span class="nf">main</span><span class="p">():</span>
    <span class="sd">&quot;&quot;&quot;Main.&quot;&quot;&quot;</span>
    <span class="n">apt_pkg</span><span class="o">.</span><span class="n">init_config</span><span class="p">()</span>
    <span class="n">apt_pkg</span><span class="o">.</span><span class="n">init_system</span><span class="p">()</span>
    <span class="n">cache</span> <span class="o">=</span> <span class="n">apt_pkg</span><span class="o">.</span><span class="n">Cache</span><span class="p">()</span>
    <span class="k">print</span> <span class="s">&quot;Essential packages:&quot;</span>
    <span class="k">for</span> <span class="n">pkg</span> <span class="ow">in</span> <span class="n">cache</span><span class="o">.</span><span class="n">packages</span><span class="p">:</span>
        <span class="k">if</span> <span class="n">pkg</span><span class="o">.</span><span class="n">essential</span><span class="p">:</span>
            <span class="k">print</span> <span class="s">&quot; &quot;</span><span class="p">,</span> <span class="n">pkg</span><span class="o">.</span><span class="n">name</span>
    <span class="k">print</span> <span class="s">&quot;Important packages:&quot;</span>
    <span class="k">for</span> <span class="n">pkg</span> <span class="ow">in</span> <span class="n">cache</span><span class="o">.</span><span class="n">packages</span><span class="p">:</span>
        <span class="k">if</span> <span class="n">pkg</span><span class="o">.</span><span class="n">important</span><span class="p">:</span>
            <span class="k">print</span> <span class="s">&quot; &quot;</span><span class="p">,</span> <span class="n">pkg</span><span class="o">.</span><span class="n">name</span>

<span class="k">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">&quot;__main__&quot;</span><span class="p">:</span>
    <span class="n">main</span><span class="p">()</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="version">
<h3><a class="reference internal" href="#apt_pkg.Version" title="apt_pkg.Version"><code class="xref py py-class docutils literal"><span class="pre">Version</span></code></a><a class="headerlink" href="#version" title="Permalink to this headline"></a></h3>
<dl class="class">
<dt id="apt_pkg.Version">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">Version</code><a class="headerlink" href="#apt_pkg.Version" title="Permalink to this definition"></a></dt>
<dd><p>The version object contains all information related to a specific package
version.</p>
<dl class="attribute">
<dt id="apt_pkg.Version.arch">
<code class="descname">arch</code><a class="headerlink" href="#apt_pkg.Version.arch" title="Permalink to this definition"></a></dt>
<dd><p>The architecture of the package, eg. amd64 or all.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Version.depends_list">
<code class="descname">depends_list</code><a class="headerlink" href="#apt_pkg.Version.depends_list" title="Permalink to this definition"></a></dt>
<dd><p>This is basically the same as <a class="reference internal" href="#apt_pkg.Version.depends_list_str" title="apt_pkg.Version.depends_list_str"><code class="xref py py-attr docutils literal"><span class="pre">depends_list_str</span></code></a>,
but instead of the (&#8216;pkgname&#8217;, &#8216;version&#8217;, &#8216;relation&#8217;) tuples,
it returns <a class="reference internal" href="#apt_pkg.Dependency" title="apt_pkg.Dependency"><code class="xref py py-class docutils literal"><span class="pre">Dependency</span></code></a> objects, which can assist you with
useful functions.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Version.depends_list_str">
<code class="descname">depends_list_str</code><a class="headerlink" href="#apt_pkg.Version.depends_list_str" title="Permalink to this definition"></a></dt>
<dd><p>A dictionary of dependencies. The key specifies the type of the
dependency (&#8216;Depends&#8217;, &#8216;Recommends&#8217;, etc.).</p>
<p>The value is a list, containing items which refer to the or-groups of
dependencies. Each of these or-groups is itself a list, containing
tuples like (&#8216;pkgname&#8217;, &#8216;version&#8217;, &#8216;relation&#8217;) for each or-choice.</p>
<p>An example return value for a package with a &#8216;Depends: python (&gt;= 2.4)&#8217;
would be:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="p">{</span><span class="s">&#39;Depends&#39;</span><span class="p">:</span> <span class="p">[</span>
                <span class="p">[</span>
                 <span class="p">(</span><span class="s">&#39;python&#39;</span><span class="p">,</span> <span class="s">&#39;2.4&#39;</span><span class="p">,</span> <span class="s">&#39;&gt;=&#39;</span><span class="p">)</span>
                <span class="p">]</span>
            <span class="p">]</span>
<span class="p">}</span>
</pre></div>
</div>
<p>The same for a dependency on A (&gt;= 1) | B (&gt;= 2):</p>
<div class="highlight-python"><div class="highlight"><pre><span class="p">{</span><span class="s">&#39;Depends&#39;</span><span class="p">:</span> <span class="p">[</span>
                <span class="p">[</span>
                    <span class="p">(</span><span class="s">&#39;A&#39;</span><span class="p">,</span> <span class="s">&#39;1&#39;</span><span class="p">,</span> <span class="s">&#39;&gt;=&#39;</span><span class="p">),</span>
                    <span class="p">(</span><span class="s">&#39;B&#39;</span><span class="p">,</span> <span class="s">&#39;2&#39;</span><span class="p">,</span> <span class="s">&#39;&gt;=&#39;</span><span class="p">),</span>
                <span class="p">]</span>
            <span class="p">]</span>
<span class="p">}</span>
</pre></div>
</div>
<p>The comparison operators are not the Debian ones, but the standard
comparison operators as used in languages such as C and Python. This
means that &#8216;&gt;&#8217; means &#8220;larger than&#8221; and &#8216;&lt;&#8217; means &#8220;less than&#8221;.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Version.downloadable">
<code class="descname">downloadable</code><a class="headerlink" href="#apt_pkg.Version.downloadable" title="Permalink to this definition"></a></dt>
<dd><p>Whether this package can be downloaded from a remote site.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Version.file_list">
<code class="descname">file_list</code><a class="headerlink" href="#apt_pkg.Version.file_list" title="Permalink to this definition"></a></dt>
<dd><p>A list of (<a class="reference internal" href="#apt_pkg.PackageFile" title="apt_pkg.PackageFile"><code class="xref py py-class docutils literal"><span class="pre">PackageFile</span></code></a>, int: index) tuples for all Package
files containing this version of the package.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Version.hash">
<code class="descname">hash</code><a class="headerlink" href="#apt_pkg.Version.hash" title="Permalink to this definition"></a></dt>
<dd><p>An integer hash value used for the internal storage.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Version.id">
<code class="descname">id</code><a class="headerlink" href="#apt_pkg.Version.id" title="Permalink to this definition"></a></dt>
<dd><p>A numeric identifier which uniquely identifies this version in all
versions in the cache.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Version.installed_size">
<code class="descname">installed_size</code><a class="headerlink" href="#apt_pkg.Version.installed_size" title="Permalink to this definition"></a></dt>
<dd><p>The size of the package (in kilobytes), when unpacked on the disk.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Version.multi_arch">
<code class="descname">multi_arch</code><a class="headerlink" href="#apt_pkg.Version.multi_arch" title="Permalink to this definition"></a></dt>
<dd><p>The multi-arch state of the package. Can be one of the following
attributes.</p>
<blockquote>
<div><dl class="attribute">
<dt id="apt_pkg.Version.MULTI_ARCH_NO">
<code class="descname">MULTI_ARCH_NO</code><a class="headerlink" href="#apt_pkg.Version.MULTI_ARCH_NO" title="Permalink to this definition"></a></dt>
<dd><p>No multi-arch</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Version.MULTI_ARCH_ALL">
<code class="descname">MULTI_ARCH_ALL</code><a class="headerlink" href="#apt_pkg.Version.MULTI_ARCH_ALL" title="Permalink to this definition"></a></dt>
<dd><p>An <code class="docutils literal"><span class="pre">Architecture:</span> <span class="pre">all</span></code> package</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Version.MULTI_ARCH_FOREIGN">
<code class="descname">MULTI_ARCH_FOREIGN</code><a class="headerlink" href="#apt_pkg.Version.MULTI_ARCH_FOREIGN" title="Permalink to this definition"></a></dt>
<dd><p>Can satisfy dependencies of foreign-architecture
packages</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Version.MULTI_ARCH_ALL_FOREIGN">
<code class="descname">MULTI_ARCH_ALL_FOREIGN</code><a class="headerlink" href="#apt_pkg.Version.MULTI_ARCH_ALL_FOREIGN" title="Permalink to this definition"></a></dt>
<dd><p><a class="reference internal" href="#apt_pkg.Version.MULTI_ARCH_FOREIGN" title="apt_pkg.Version.MULTI_ARCH_FOREIGN"><code class="xref py py-attr docutils literal"><span class="pre">MULTI_ARCH_FOREIGN</span></code></a> for <code class="docutils literal"><span class="pre">Architecture:</span> <span class="pre">all</span></code>
packages.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Version.MULTI_ARCH_SAME">
<code class="descname">MULTI_ARCH_SAME</code><a class="headerlink" href="#apt_pkg.Version.MULTI_ARCH_SAME" title="Permalink to this definition"></a></dt>
<dd><p>Multiple versions from different architectures may be
installed in parallel, but may only satisfy dependencies
of packages from the same architecture</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Version.MULTI_ARCH_ALLOWED">
<code class="descname">MULTI_ARCH_ALLOWED</code><a class="headerlink" href="#apt_pkg.Version.MULTI_ARCH_ALLOWED" title="Permalink to this definition"></a></dt>
<dd><p>Installation in parallel and satisfying <code class="docutils literal"><span class="pre">pkg:any</span></code>
style dependencies is allowed.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Version.MULTI_ARCH_ALL_ALLOWED">
<code class="descname">MULTI_ARCH_ALL_ALLOWED</code><a class="headerlink" href="#apt_pkg.Version.MULTI_ARCH_ALL_ALLOWED" title="Permalink to this definition"></a></dt>
<dd><p><a class="reference internal" href="#apt_pkg.Version.MULTI_ARCH_ALLOWED" title="apt_pkg.Version.MULTI_ARCH_ALLOWED"><code class="xref py py-attr docutils literal"><span class="pre">MULTI_ARCH_ALLOWED</span></code></a> for <code class="docutils literal"><span class="pre">Architecture:</span> <span class="pre">all</span></code>
packages.</p>
</dd></dl>

</div></blockquote>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Version.parent_pkg">
<code class="descname">parent_pkg</code><a class="headerlink" href="#apt_pkg.Version.parent_pkg" title="Permalink to this definition"></a></dt>
<dd><p>The <a class="reference internal" href="#apt_pkg.Package" title="apt_pkg.Package"><code class="xref py py-class docutils literal"><span class="pre">Package</span></code></a> object this version belongs to.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Version.priority">
<code class="descname">priority</code><a class="headerlink" href="#apt_pkg.Version.priority" title="Permalink to this definition"></a></dt>
<dd><p>The integer representation of the priority. This can be used to speed
up comparisons a lot, compared to <a class="reference internal" href="#apt_pkg.Version.priority_str" title="apt_pkg.Version.priority_str"><code class="xref py py-attr docutils literal"><span class="pre">priority_str</span></code></a>.</p>
<p>The values are defined in the <a class="reference internal" href="#module-apt_pkg" title="apt_pkg"><code class="xref py py-mod docutils literal"><span class="pre">apt_pkg</span></code></a> extension, see
<a class="reference internal" href="#priorities"><span>Priorities</span></a> for more information.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Version.priority_str">
<code class="descname">priority_str</code><a class="headerlink" href="#apt_pkg.Version.priority_str" title="Permalink to this definition"></a></dt>
<dd><p>Return the priority of the package version, as a string, eg.
&#8220;optional&#8221;.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Version.provides_list">
<code class="descname">provides_list</code><a class="headerlink" href="#apt_pkg.Version.provides_list" title="Permalink to this definition"></a></dt>
<dd><p>This returns a list of all packages provided by this version. Like
<a class="reference internal" href="#apt_pkg.Package.provides_list" title="apt_pkg.Package.provides_list"><code class="xref py py-attr docutils literal"><span class="pre">Package.provides_list</span></code></a>, it returns a list of tuples
of the form (&#8216;virtualpkgname&#8217;, &#8216;&#8217;, <a class="reference internal" href="#apt_pkg.Version" title="apt_pkg.Version"><code class="xref py py-class docutils literal"><span class="pre">Version</span></code></a>), where as the
last item is the same as the object itself.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Version.section">
<code class="descname">section</code><a class="headerlink" href="#apt_pkg.Version.section" title="Permalink to this definition"></a></dt>
<dd><p>The usual sections (eg. admin, net, etc.). Prefixed with the component
name for packages not in main (eg. non-free/admin).</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Version.size">
<code class="descname">size</code><a class="headerlink" href="#apt_pkg.Version.size" title="Permalink to this definition"></a></dt>
<dd><p>The size of the .deb file, in bytes.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Version.translated_description">
<code class="descname">translated_description</code><a class="headerlink" href="#apt_pkg.Version.translated_description" title="Permalink to this definition"></a></dt>
<dd><p>Return a <a class="reference internal" href="#apt_pkg.Description" title="apt_pkg.Description"><code class="xref py py-class docutils literal"><span class="pre">Description</span></code></a> object for the translated description
of this package version.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Version.ver_str">
<code class="descname">ver_str</code><a class="headerlink" href="#apt_pkg.Version.ver_str" title="Permalink to this definition"></a></dt>
<dd><p>The version, as a string.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="dependency">
<h3><a class="reference internal" href="#apt_pkg.Dependency" title="apt_pkg.Dependency"><code class="xref py py-class docutils literal"><span class="pre">Dependency</span></code></a><a class="headerlink" href="#dependency" title="Permalink to this headline"></a></h3>
<dl class="class">
<dt id="apt_pkg.Dependency">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">Dependency</code><a class="headerlink" href="#apt_pkg.Dependency" title="Permalink to this definition"></a></dt>
<dd><p>Represent a dependency from one package to another one.</p>
<dl class="method">
<dt id="apt_pkg.Dependency.all_targets">
<code class="descname">all_targets</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.Dependency.all_targets" title="Permalink to this definition"></a></dt>
<dd><p>A list of all possible target <a class="reference internal" href="#apt_pkg.Version" title="apt_pkg.Version"><code class="xref py py-class docutils literal"><span class="pre">Version</span></code></a> objects which satisfy
this dependency.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.Dependency.smart_target_pkg">
<code class="descname">smart_target_pkg</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.Dependency.smart_target_pkg" title="Permalink to this definition"></a></dt>
<dd><p>Return a <a class="reference internal" href="#apt_pkg.Version" title="apt_pkg.Version"><code class="xref py py-class docutils literal"><span class="pre">Version</span></code></a> object of a package which satisfies the
dependency and does not conflict with installed packages
(the &#8216;natural target&#8217;).</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Dependency.comp_type">
<code class="descname">comp_type</code><a class="headerlink" href="#apt_pkg.Dependency.comp_type" title="Permalink to this definition"></a></dt>
<dd><p>The type of comparison (&lt;,&lt;=,=,!=,&gt;=,&gt;,), as string. Note that the
empty string is a valid string as well, if no version is specified.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Dependency.dep_type">
<code class="descname">dep_type</code><a class="headerlink" href="#apt_pkg.Dependency.dep_type" title="Permalink to this definition"></a></dt>
<dd><p>The type of the dependency, as string, eg. &#8220;Depends&#8221;.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Dependency.dep_type_enum">
<code class="descname">dep_type_enum</code><a class="headerlink" href="#apt_pkg.Dependency.dep_type_enum" title="Permalink to this definition"></a></dt>
<dd><p>The type of the dependency, as an integer which can be compared to
one of the TYPE_* constants below.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Dependency.dep_type_untranslated">
<code class="descname">dep_type_untranslated</code><a class="headerlink" href="#apt_pkg.Dependency.dep_type_untranslated" title="Permalink to this definition"></a></dt>
<dd><p>The type of the depndency, as an untranslated string.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Dependency.id">
<code class="descname">id</code><a class="headerlink" href="#apt_pkg.Dependency.id" title="Permalink to this definition"></a></dt>
<dd><p>The ID of the package, as integer.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Dependency.parent_pkg">
<code class="descname">parent_pkg</code><a class="headerlink" href="#apt_pkg.Dependency.parent_pkg" title="Permalink to this definition"></a></dt>
<dd><p>The <a class="reference internal" href="#apt_pkg.Package" title="apt_pkg.Package"><code class="xref py py-class docutils literal"><span class="pre">Package</span></code></a> object of the package which declares the
dependency. This is the same as using ParentVer.ParentPkg.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Dependency.parent_ver">
<code class="descname">parent_ver</code><a class="headerlink" href="#apt_pkg.Dependency.parent_ver" title="Permalink to this definition"></a></dt>
<dd><p>The <a class="reference internal" href="#apt_pkg.Version" title="apt_pkg.Version"><code class="xref py py-class docutils literal"><span class="pre">Version</span></code></a> object of the parent version, ie. the package
which declares the dependency.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Dependency.target_pkg">
<code class="descname">target_pkg</code><a class="headerlink" href="#apt_pkg.Dependency.target_pkg" title="Permalink to this definition"></a></dt>
<dd><p>The <a class="reference internal" href="#apt_pkg.Package" title="apt_pkg.Package"><code class="xref py py-class docutils literal"><span class="pre">Package</span></code></a> object of the target package.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Dependency.target_ver">
<code class="descname">target_ver</code><a class="headerlink" href="#apt_pkg.Dependency.target_ver" title="Permalink to this definition"></a></dt>
<dd><p>The target version of the dependency, as string. Empty string if the
dependency is not versioned.</p>
</dd></dl>

<p>The following constants describe all values the attribute <em>dep_type_enum</em>
can take:</p>
<dl class="attribute">
<dt id="apt_pkg.Dependency.TYPE_CONFLICTS">
<code class="descname">TYPE_CONFLICTS</code><a class="headerlink" href="#apt_pkg.Dependency.TYPE_CONFLICTS" title="Permalink to this definition"></a></dt>
<dd><p>Constant for checking against dep_type_enum</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Dependency.TYPE_DEPENDS">
<code class="descname">TYPE_DEPENDS</code><a class="headerlink" href="#apt_pkg.Dependency.TYPE_DEPENDS" title="Permalink to this definition"></a></dt>
<dd><p>Constant for checking against dep_type_enum</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Dependency.TYPE_DPKG_BREAKS">
<code class="descname">TYPE_DPKG_BREAKS</code><a class="headerlink" href="#apt_pkg.Dependency.TYPE_DPKG_BREAKS" title="Permalink to this definition"></a></dt>
<dd><p>Constant for checking against dep_type_enum</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Dependency.TYPE_ENHANCES">
<code class="descname">TYPE_ENHANCES</code><a class="headerlink" href="#apt_pkg.Dependency.TYPE_ENHANCES" title="Permalink to this definition"></a></dt>
<dd><p>Constant for checking against dep_type_enum</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Dependency.TYPE_OBSOLETES">
<code class="descname">TYPE_OBSOLETES</code><a class="headerlink" href="#apt_pkg.Dependency.TYPE_OBSOLETES" title="Permalink to this definition"></a></dt>
<dd><p>Constant for checking against dep_type_enum</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Dependency.TYPE_PREDEPENDS">
<code class="descname">TYPE_PREDEPENDS</code><a class="headerlink" href="#apt_pkg.Dependency.TYPE_PREDEPENDS" title="Permalink to this definition"></a></dt>
<dd><p>Constant for checking against dep_type_enum</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Dependency.TYPE_RECOMMENDS">
<code class="descname">TYPE_RECOMMENDS</code><a class="headerlink" href="#apt_pkg.Dependency.TYPE_RECOMMENDS" title="Permalink to this definition"></a></dt>
<dd><p>Constant for checking against dep_type_enum</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Dependency.TYPE_REPLACES">
<code class="descname">TYPE_REPLACES</code><a class="headerlink" href="#apt_pkg.Dependency.TYPE_REPLACES" title="Permalink to this definition"></a></dt>
<dd><p>Constant for checking against dep_type_enum</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Dependency.TYPE_SUGGESTS">
<code class="descname">TYPE_SUGGESTS</code><a class="headerlink" href="#apt_pkg.Dependency.TYPE_SUGGESTS" title="Permalink to this definition"></a></dt>
<dd><p>Constant for checking against dep_type_enum</p>
</dd></dl>

</dd></dl>

<div class="section" id="example-find-all-missing-dependencies">
<h4>Example: Find all missing dependencies<a class="headerlink" href="#example-find-all-missing-dependencies" title="Permalink to this headline"></a></h4>
<p>With the help of Dependency.AllTargets(), you can easily find all packages with
broken dependencies:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c">#!/usr/bin/python</span>
<span class="sd">&quot;&quot;&quot;Check the archive for missing dependencies&quot;&quot;&quot;</span>
<span class="kn">import</span> <span class="nn">apt_pkg</span>


<span class="k">def</span> <span class="nf">fmt_dep</span><span class="p">(</span><span class="n">dep</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Format a Dependency object [of apt_pkg] as a string.&quot;&quot;&quot;</span>
    <span class="n">ret</span> <span class="o">=</span> <span class="n">dep</span><span class="o">.</span><span class="n">target_pkg</span><span class="o">.</span><span class="n">name</span>
    <span class="k">if</span> <span class="n">dep</span><span class="o">.</span><span class="n">target_ver</span><span class="p">:</span>
        <span class="n">ret</span> <span class="o">+=</span> <span class="s">&quot; (</span><span class="si">%s</span><span class="s"> </span><span class="si">%s</span><span class="s">)&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">dep</span><span class="o">.</span><span class="n">comp_type</span><span class="p">,</span> <span class="n">dep</span><span class="o">.</span><span class="n">target_ver</span><span class="p">)</span>
    <span class="k">return</span> <span class="n">ret</span>


<span class="k">def</span> <span class="nf">check_version</span><span class="p">(</span><span class="n">pkgver</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Check the version of the package&quot;&quot;&quot;</span>
    <span class="n">missing</span> <span class="o">=</span> <span class="p">[]</span>

    <span class="k">for</span> <span class="n">or_group</span> <span class="ow">in</span> <span class="n">pkgver</span><span class="o">.</span><span class="n">depends_list</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">&quot;Pre-Depends&quot;</span><span class="p">,</span> <span class="p">[])</span> <span class="o">+</span> \
                    <span class="n">pkgver</span><span class="o">.</span><span class="n">depends_list</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">&quot;Depends&quot;</span><span class="p">,</span> <span class="p">[]):</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="nb">any</span><span class="p">(</span><span class="n">dep</span><span class="o">.</span><span class="n">all_targets</span><span class="p">()</span> <span class="k">for</span> <span class="n">dep</span> <span class="ow">in</span> <span class="n">or_group</span><span class="p">):</span>
            <span class="c"># If none of the or-choices can be satisfied, add it to missing</span>
            <span class="n">missing</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">or_group</span><span class="p">)</span>

    <span class="k">if</span> <span class="n">missing</span><span class="p">:</span>
        <span class="k">print</span> <span class="s">&quot;Package:&quot;</span><span class="p">,</span> <span class="n">pkgver</span><span class="o">.</span><span class="n">parent_pkg</span><span class="o">.</span><span class="n">name</span>
        <span class="k">print</span> <span class="s">&quot;Version:&quot;</span><span class="p">,</span> <span class="n">pkgver</span><span class="o">.</span><span class="n">ver_str</span>
        <span class="k">print</span> <span class="s">&quot;Missing:&quot;</span><span class="p">,</span>
        <span class="k">print</span> <span class="s">&quot;, &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="s">&quot; | &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">fmt_dep</span><span class="p">(</span><span class="n">dep</span><span class="p">)</span> <span class="k">for</span> <span class="n">dep</span> <span class="ow">in</span> <span class="n">or_group</span><span class="p">)</span>
                        <span class="k">for</span> <span class="n">or_group</span> <span class="ow">in</span> <span class="n">missing</span><span class="p">)</span>
        <span class="k">print</span>


<span class="k">def</span> <span class="nf">main</span><span class="p">():</span>
    <span class="sd">&quot;&quot;&quot;The main function.&quot;&quot;&quot;</span>
    <span class="n">apt_pkg</span><span class="o">.</span><span class="n">init_config</span><span class="p">()</span>
    <span class="n">apt_pkg</span><span class="o">.</span><span class="n">init_system</span><span class="p">()</span>

    <span class="n">cache</span> <span class="o">=</span> <span class="n">apt_pkg</span><span class="o">.</span><span class="n">Cache</span><span class="p">()</span>

    <span class="k">for</span> <span class="n">pkg</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">cache</span><span class="o">.</span><span class="n">packages</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">pkg</span><span class="p">:</span> <span class="n">pkg</span><span class="o">.</span><span class="n">name</span><span class="p">):</span>
        <span class="c"># pkg is from a list of packages, sorted by name.</span>
        <span class="k">for</span> <span class="n">version</span> <span class="ow">in</span> <span class="n">pkg</span><span class="o">.</span><span class="n">version_list</span><span class="p">:</span>
            <span class="c"># Check every version</span>
            <span class="k">for</span> <span class="n">pfile</span><span class="p">,</span> <span class="n">_</span> <span class="ow">in</span> <span class="n">version</span><span class="o">.</span><span class="n">file_list</span><span class="p">:</span>
                <span class="k">if</span> <span class="p">(</span><span class="n">pfile</span><span class="o">.</span><span class="n">origin</span> <span class="o">==</span> <span class="s">&quot;Debian&quot;</span> <span class="ow">and</span> <span class="n">pfile</span><span class="o">.</span><span class="n">component</span> <span class="o">==</span> <span class="s">&quot;main&quot;</span> <span class="ow">and</span>
                        <span class="n">pfile</span><span class="o">.</span><span class="n">archive</span> <span class="o">==</span> <span class="s">&quot;unstable&quot;</span><span class="p">):</span>
                    <span class="c"># We only want packages from Debian unstable main.</span>
                    <span class="n">check_version</span><span class="p">(</span><span class="n">version</span><span class="p">)</span>
                    <span class="k">break</span>

<span class="k">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">&quot;__main__&quot;</span><span class="p">:</span>
    <span class="n">main</span><span class="p">()</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="description">
<h3><a class="reference internal" href="#apt_pkg.Description" title="apt_pkg.Description"><code class="xref py py-class docutils literal"><span class="pre">Description</span></code></a><a class="headerlink" href="#description" title="Permalink to this headline"></a></h3>
<dl class="class">
<dt id="apt_pkg.Description">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">Description</code><a class="headerlink" href="#apt_pkg.Description" title="Permalink to this definition"></a></dt>
<dd><p>Represent the description of the package.</p>
<dl class="attribute">
<dt id="apt_pkg.Description.language_code">
<code class="descname">language_code</code><a class="headerlink" href="#apt_pkg.Description.language_code" title="Permalink to this definition"></a></dt>
<dd><p>The language code of the description; or, if the description
is untranslated, an empty string.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Description.md5">
<code class="descname">md5</code><a class="headerlink" href="#apt_pkg.Description.md5" title="Permalink to this definition"></a></dt>
<dd><p>The MD5 checksum of the description.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Description.file_list">
<code class="descname">file_list</code><a class="headerlink" href="#apt_pkg.Description.file_list" title="Permalink to this definition"></a></dt>
<dd><p>A list of tuples <code class="docutils literal"><span class="pre">(packagefile:</span> <span class="pre">PackageFile,</span> <span class="pre">index:</span> <span class="pre">int)</span></code>.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="package-pinning-with-policy">
<h3>Package Pinning with <a class="reference internal" href="#apt_pkg.Policy" title="apt_pkg.Policy"><code class="xref py py-class docutils literal"><span class="pre">Policy</span></code></a><a class="headerlink" href="#package-pinning-with-policy" title="Permalink to this headline"></a></h3>
<dl class="class">
<dt id="apt_pkg.Policy">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">Policy</code><span class="sig-paren">(</span><em>cache: apt_pkg.Cache</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.Policy" title="Permalink to this definition"></a></dt>
<dd><p>Representation of the policy of the <a class="reference internal" href="#apt_pkg.Cache" title="apt_pkg.Cache"><code class="xref py py-class docutils literal"><span class="pre">Cache</span></code></a> object given by
<em>cache</em>. This provides a superset of policy-related functionality
compared to the <em>DepCache</em> class. The DepCache can be used for most
purposes, but there may be some cases where a special policy class
is needed.</p>
<dl class="method">
<dt id="apt_pkg.Policy.create_pin">
<code class="descname">create_pin</code><span class="sig-paren">(</span><em>type: str</em>, <em>pkg: str</em>, <em>data: str</em>, <em>priority: int</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.Policy.create_pin" title="Permalink to this definition"></a></dt>
<dd><p>Create a pin for the policy. The parameter <em>type</em> refers to one of the
strings &#8216;Version&#8217;, &#8216;Release&#8217;, or &#8216;Origin&#8217;. The argument <em>pkg</em> is the
name of the package. The parameter <em>data</em> refers to the value (such
as &#8216;unstable&#8217; for type=&#8217;Release&#8217;) and the other possible options.
The parameter &#8216;priority&#8217; gives the priority of the pin.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.Policy.get_candidate_ver">
<code class="descname">get_candidate_ver</code><span class="sig-paren">(</span><em>package: apt_pkg.Package</em><span class="sig-paren">)</span> &rarr; apt_pkg.Version<a class="headerlink" href="#apt_pkg.Policy.get_candidate_ver" title="Permalink to this definition"></a></dt>
<dd><p>Get the best package for the job; that is, the package with the
highest pin priority.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.Policy.get_match">
<code class="descname">get_match</code><span class="sig-paren">(</span><em>package: apt_pkg.Package</em><span class="sig-paren">)</span> &rarr; apt_pkg.Version<a class="headerlink" href="#apt_pkg.Policy.get_match" title="Permalink to this definition"></a></dt>
<dd><p>Get a version for the package.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.Policy.get_priority">
<code class="descname">get_priority</code><span class="sig-paren">(</span><em>package: apt_pkg.Package</em><span class="sig-paren">)</span> &rarr; int<a class="headerlink" href="#apt_pkg.Policy.get_priority" title="Permalink to this definition"></a></dt>
<dd><p>Get the pin priority of the package given by <em>package</em>.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.Policy.read_pindir">
<code class="descname">read_pindir</code><span class="sig-paren">(</span><em>dirname: str</em><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.Policy.read_pindir" title="Permalink to this definition"></a></dt>
<dd><p>Read the pin files in the given dir (e.g. &#8216;/etc/apt/preferences.d&#8217;)
and add them to the policy.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.Policy.read_pinfile">
<code class="descname">read_pinfile</code><span class="sig-paren">(</span><em>filename: str</em><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.Policy.read_pinfile" title="Permalink to this definition"></a></dt>
<dd><p>Read the pin file given by <em>filename</em> (e.g. &#8216;/etc/apt/preferences&#8217;)
and add it to the policy.</p>
</dd></dl>

</dd></dl>

</div>
</div>
<div class="section" id="index-files">
<h2>Index Files<a class="headerlink" href="#index-files" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="apt_pkg.MetaIndex">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">MetaIndex</code><a class="headerlink" href="#apt_pkg.MetaIndex" title="Permalink to this definition"></a></dt>
<dd><p>Represent a Release file as stored in the cache.</p>
<blockquote>
<div><dl class="attribute">
<dt id="apt_pkg.MetaIndex.uri">
<code class="descname">uri</code><a class="headerlink" href="#apt_pkg.MetaIndex.uri" title="Permalink to this definition"></a></dt>
<dd><p>The URI the meta index file is located at, as a string.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.MetaIndex.dist">
<code class="descname">dist</code><a class="headerlink" href="#apt_pkg.MetaIndex.dist" title="Permalink to this definition"></a></dt>
<dd><p>The distribution stored in the meta index, as a string.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.MetaIndex.is_trusted">
<code class="descname">is_trusted</code><a class="headerlink" href="#apt_pkg.MetaIndex.is_trusted" title="Permalink to this definition"></a></dt>
<dd><p>A boolean value determining whether the meta index can be trusted. This
is <code class="docutils literal"><span class="pre">True</span></code> for signed Release files.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.MetaIndex.index_files">
<code class="descname">index_files</code><a class="headerlink" href="#apt_pkg.MetaIndex.index_files" title="Permalink to this definition"></a></dt>
<dd><p>A list of all <a class="reference internal" href="#apt_pkg.IndexFile" title="apt_pkg.IndexFile"><code class="xref py py-class docutils literal"><span class="pre">IndexFile</span></code></a> objects associated with this meta
index.</p>
</dd></dl>

</div></blockquote>
</dd></dl>

<dl class="class">
<dt id="apt_pkg.IndexFile">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">IndexFile</code><a class="headerlink" href="#apt_pkg.IndexFile" title="Permalink to this definition"></a></dt>
<dd><p>Represent an index file, that is, package indexes, translation indexes,
and source indexes.</p>
<dl class="method">
<dt id="apt_pkg.IndexFile.archive_uri">
<code class="descname">archive_uri</code><span class="sig-paren">(</span><em>path: str</em><span class="sig-paren">)</span> &rarr; str<a class="headerlink" href="#apt_pkg.IndexFile.archive_uri" title="Permalink to this definition"></a></dt>
<dd><p>Return the URI to the given path in the archive.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.IndexFile.label">
<code class="descname">label</code><a class="headerlink" href="#apt_pkg.IndexFile.label" title="Permalink to this definition"></a></dt>
<dd><p>The label of the index file.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.IndexFile.describe">
<code class="descname">describe</code><a class="headerlink" href="#apt_pkg.IndexFile.describe" title="Permalink to this definition"></a></dt>
<dd><p>A string describing this object.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.IndexFile.exists">
<code class="descname">exists</code><a class="headerlink" href="#apt_pkg.IndexFile.exists" title="Permalink to this definition"></a></dt>
<dd><p>A boolean value determining whether the index file exists.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.IndexFile.has_packages">
<code class="descname">has_packages</code><a class="headerlink" href="#apt_pkg.IndexFile.has_packages" title="Permalink to this definition"></a></dt>
<dd><p>A boolean value determining whether the index file has packages.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.IndexFile.size">
<code class="descname">size</code><a class="headerlink" href="#apt_pkg.IndexFile.size" title="Permalink to this definition"></a></dt>
<dd><p>The size of the file, measured in bytes.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.IndexFile.is_trusted">
<code class="descname">is_trusted</code><a class="headerlink" href="#apt_pkg.IndexFile.is_trusted" title="Permalink to this definition"></a></dt>
<dd><p>A boolean value determining whether the file can be trusted; that is,
because it is from a source with a GPG signed Release file.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="apt_pkg.PackageFile">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">PackageFile</code><a class="headerlink" href="#apt_pkg.PackageFile" title="Permalink to this definition"></a></dt>
<dd><p>Provide access to an index file stored in the cache, such as
<code class="file docutils literal"><span class="pre">/var/lib/dpkg/status</span></code>.</p>
<dl class="attribute">
<dt id="apt_pkg.PackageFile.architecture">
<code class="descname">architecture</code><a class="headerlink" href="#apt_pkg.PackageFile.architecture" title="Permalink to this definition"></a></dt>
<dd><p>The architecture of the package file. This attribute normally
contains an empty string and is thus not very useful.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.PackageFile.archive">
<code class="descname">archive</code><a class="headerlink" href="#apt_pkg.PackageFile.archive" title="Permalink to this definition"></a></dt>
<dd><p>The archive of the package file as set in the Release file via
the &#8220;Suite&#8221; field. If there is no Release file, this is an empty
string.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.PackageFile.component">
<code class="descname">component</code><a class="headerlink" href="#apt_pkg.PackageFile.component" title="Permalink to this definition"></a></dt>
<dd><p>The component of the package file, if it is provided by a repository
using the dists/ hierarchy. For other packages files, this property
is an empty string.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.PackageFile.filename">
<code class="descname">filename</code><a class="headerlink" href="#apt_pkg.PackageFile.filename" title="Permalink to this definition"></a></dt>
<dd><p>The path to the file on the local filesystem.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.PackageFile.id">
<code class="descname">id</code><a class="headerlink" href="#apt_pkg.PackageFile.id" title="Permalink to this definition"></a></dt>
<dd><p>The ID of the package. This is an integer which can be used to store
further information about the file [eg. as dictionary key].</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.PackageFile.index_type">
<code class="descname">index_type</code><a class="headerlink" href="#apt_pkg.PackageFile.index_type" title="Permalink to this definition"></a></dt>
<dd><p>A string describing the type of index. Known values are
&#8220;Debian Package Index&#8221;, &#8220;Debian Translation Index&#8221;, and
&#8220;Debian dpkg status file&#8221;.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.PackageFile.label">
<code class="descname">label</code><a class="headerlink" href="#apt_pkg.PackageFile.label" title="Permalink to this definition"></a></dt>
<dd><p>The label of the package file as set in the release file
via the &#8216;Label&#8217; field. If there is no Release file, this
attribute is an empty string.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.PackageFile.not_automatic">
<code class="descname">not_automatic</code><a class="headerlink" href="#apt_pkg.PackageFile.not_automatic" title="Permalink to this definition"></a></dt>
<dd><p>Whether packages from this list will be updated automatically. The
default for example is False.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.PackageFile.not_source">
<code class="descname">not_source</code><a class="headerlink" href="#apt_pkg.PackageFile.not_source" title="Permalink to this definition"></a></dt>
<dd><p>Whether the file has no source from which it can be updated. In such a
case, the value is <code class="docutils literal"><span class="pre">True</span></code>; else <code class="docutils literal"><span class="pre">False</span></code>. For example, it is
<code class="docutils literal"><span class="pre">False</span></code> for <code class="file docutils literal"><span class="pre">/var/lib/dpkg/status</span></code>.</p>
<p>Example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">for</span> <span class="n">pkgfile</span> <span class="ow">in</span> <span class="n">cache</span><span class="o">.</span><span class="n">file_list</span><span class="p">:</span>
    <span class="k">if</span> <span class="n">pkgfile</span><span class="o">.</span><span class="n">not_source</span><span class="p">:</span>
        <span class="k">print</span> <span class="s">&#39;The file </span><span class="si">%s</span><span class="s"> has no source.&#39;</span> <span class="o">%</span> <span class="n">pkgfile</span><span class="o">.</span><span class="n">filename</span>
</pre></div>
</div>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.PackageFile.origin">
<code class="descname">origin</code><a class="headerlink" href="#apt_pkg.PackageFile.origin" title="Permalink to this definition"></a></dt>
<dd><p>The Origin, as set in the Release file</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.PackageFile.site">
<code class="descname">site</code><a class="headerlink" href="#apt_pkg.PackageFile.site" title="Permalink to this definition"></a></dt>
<dd><p>The hostname of the site.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.PackageFile.size">
<code class="descname">size</code><a class="headerlink" href="#apt_pkg.PackageFile.size" title="Permalink to this definition"></a></dt>
<dd><p>The size of the file.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.PackageFile.version">
<code class="descname">version</code><a class="headerlink" href="#apt_pkg.PackageFile.version" title="Permalink to this definition"></a></dt>
<dd><p>The version, as set in the release file (eg. &#8220;4.0&#8221; for &#8220;Etch&#8221;)</p>
</dd></dl>

</dd></dl>

<p>The following example shows how to use PackageFile:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c">#!/usr/bin/python</span>
<span class="kn">import</span> <span class="nn">apt_pkg</span>


<span class="k">def</span> <span class="nf">main</span><span class="p">():</span>
    <span class="sd">&quot;&quot;&quot;Example for PackageFile()&quot;&quot;&quot;</span>
    <span class="n">apt_pkg</span><span class="o">.</span><span class="n">init</span><span class="p">()</span>
    <span class="n">cache</span> <span class="o">=</span> <span class="n">apt_pkg</span><span class="o">.</span><span class="n">Cache</span><span class="p">()</span>
    <span class="k">for</span> <span class="n">pkgfile</span> <span class="ow">in</span> <span class="n">cache</span><span class="o">.</span><span class="n">file_list</span><span class="p">:</span>
        <span class="k">print</span> <span class="s">&#39;Package-File:&#39;</span><span class="p">,</span> <span class="n">pkgfile</span><span class="o">.</span><span class="n">filename</span>
        <span class="k">print</span> <span class="s">&#39;Index-Type:&#39;</span><span class="p">,</span> <span class="n">pkgfile</span><span class="o">.</span><span class="n">index_type</span>  <span class="c"># &#39;Debian Package Index&#39;</span>
        <span class="k">if</span> <span class="n">pkgfile</span><span class="o">.</span><span class="n">not_source</span><span class="p">:</span>
            <span class="k">print</span> <span class="s">&#39;Source: None&#39;</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">pkgfile</span><span class="o">.</span><span class="n">site</span><span class="p">:</span>
                <span class="c"># There is a source, and a site, print the site</span>
                <span class="k">print</span> <span class="s">&#39;Source:&#39;</span><span class="p">,</span> <span class="n">pkgfile</span><span class="o">.</span><span class="n">site</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="c"># It seems to be a local repository</span>
                <span class="k">print</span> <span class="s">&#39;Source: Local package file&#39;</span>
        <span class="k">if</span> <span class="n">pkgfile</span><span class="o">.</span><span class="n">not_automatic</span><span class="p">:</span>
            <span class="c"># The system won&#39;t be updated automatically (eg. experimental)</span>
            <span class="k">print</span> <span class="s">&#39;Automatic: No&#39;</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">print</span> <span class="s">&#39;Automatic: Yes&#39;</span>
        <span class="k">print</span>

<span class="k">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">&#39;__main__&#39;</span><span class="p">:</span>
    <span class="n">main</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="section" id="records-release-files-packages-sources">
<h2>Records (Release files, Packages, Sources)<a class="headerlink" href="#records-release-files-packages-sources" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="apt_pkg.IndexRecords">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">IndexRecords</code><a class="headerlink" href="#apt_pkg.IndexRecords" title="Permalink to this definition"></a></dt>
<dd><p>Represent a Release file and provide means to read information from
the file. This class provides several methods:</p>
<dl class="method">
<dt id="apt_pkg.IndexRecords.get_dist">
<code class="descname">get_dist</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &rarr; str<a class="headerlink" href="#apt_pkg.IndexRecords.get_dist" title="Permalink to this definition"></a></dt>
<dd><p>Return the distribution set in the Release file.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.IndexRecords.load">
<code class="descname">load</code><span class="sig-paren">(</span><em>filename: str</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.IndexRecords.load" title="Permalink to this definition"></a></dt>
<dd><p>Load the file located at the path given by <em>filename</em>.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.IndexRecords.lookup">
<code class="descname">lookup</code><span class="sig-paren">(</span><em>key: str) -&gt; (HashString</em>, <em>int</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.IndexRecords.lookup" title="Permalink to this definition"></a></dt>
<dd><p>Look up the filename given by <em>key</em> and return a tuple (hash, size),
where the first element <em>hash</em> is a <a class="reference internal" href="#apt_pkg.HashString" title="apt_pkg.HashString"><code class="xref py py-class docutils literal"><span class="pre">HashString</span></code></a> object
and the second element <em>size</em> is an int object.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="apt_pkg.PackageRecords">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">PackageRecords</code><span class="sig-paren">(</span><em>cache: apt_pkg.Cache</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.PackageRecords" title="Permalink to this definition"></a></dt>
<dd><p>Provide further information about the packages in the <a class="reference internal" href="#apt_pkg.Cache" title="apt_pkg.Cache"><code class="xref py py-class docutils literal"><span class="pre">Cache</span></code></a> object
<em>cache</em>. This efficiently parses the package files to provide information
not available in the cache, such as maintainer, hash sums, description,
and the file name of the package. It also provides the complete record
of the package.</p>
<dl class="method">
<dt id="apt_pkg.PackageRecords.lookup">
<code class="descname">lookup</code><span class="sig-paren">(</span><em>verfile_iter: (PackageFile</em>, <em>int)</em><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.PackageRecords.lookup" title="Permalink to this definition"></a></dt>
<dd><p>Change the actual package to the package given by the verfile_iter.</p>
<p>The parameter <em>verfile_iter</em> refers to a tuple consisting
of (<a class="reference internal" href="#apt_pkg.PackageFile" title="apt_pkg.PackageFile"><code class="xref py py-class docutils literal"><span class="pre">PackageFile()</span></code></a>, int: index), as returned by various
<code class="docutils literal"><span class="pre">file_list</span></code> attributes such as <a class="reference internal" href="#apt_pkg.Version.file_list" title="apt_pkg.Version.file_list"><code class="xref py py-attr docutils literal"><span class="pre">Version.file_list</span></code></a>.</p>
<p>Example (shortened):</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">cand</span> <span class="o">=</span> <span class="n">depcache</span><span class="o">.</span><span class="n">get_candidate_ver</span><span class="p">(</span><span class="n">cache</span><span class="p">[</span><span class="s">&#39;python-apt&#39;</span><span class="p">])</span>
<span class="n">records</span><span class="o">.</span><span class="n">lookup</span><span class="p">(</span><span class="n">cand</span><span class="o">.</span><span class="n">file_list</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
<span class="c"># Now you can access the record</span>
<span class="k">print</span> <span class="n">records</span><span class="o">.</span><span class="n">source_pkg</span> <span class="c"># == python-apt</span>
</pre></div>
</div>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.PackageRecords.filename">
<code class="descname">filename</code><a class="headerlink" href="#apt_pkg.PackageRecords.filename" title="Permalink to this definition"></a></dt>
<dd><p>Return the field &#8216;Filename&#8217; of the record. This is the path to the
package, relative to the base path of the archive.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.PackageRecords.md5_hash">
<code class="descname">md5_hash</code><a class="headerlink" href="#apt_pkg.PackageRecords.md5_hash" title="Permalink to this definition"></a></dt>
<dd><p>Return the MD5 hashsum of the package This refers to the field
&#8216;MD5Sum&#8217; in the raw record.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.PackageRecords.sha1_hash">
<code class="descname">sha1_hash</code><a class="headerlink" href="#apt_pkg.PackageRecords.sha1_hash" title="Permalink to this definition"></a></dt>
<dd><p>Return the SHA1 hashsum of the package. This refers to the field &#8216;SHA1&#8217;
in the raw record.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.PackageRecords.sha256_hash">
<code class="descname">sha256_hash</code><a class="headerlink" href="#apt_pkg.PackageRecords.sha256_hash" title="Permalink to this definition"></a></dt>
<dd><p>Return the SHA256 hashsum of the package. This refers to the field
&#8216;SHA256&#8217; in the raw record.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.7.9.</span></p>
</div>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.PackageRecords.source_pkg">
<code class="descname">source_pkg</code><a class="headerlink" href="#apt_pkg.PackageRecords.source_pkg" title="Permalink to this definition"></a></dt>
<dd><p>The name of the source package, if different from the name of the
binary package. This information is retrieved from the &#8216;Source&#8217; field.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.PackageRecords.source_ver">
<code class="descname">source_ver</code><a class="headerlink" href="#apt_pkg.PackageRecords.source_ver" title="Permalink to this definition"></a></dt>
<dd><p>The version of the source package, if it differs from the version
of the binary package. Just like &#8216;source_pkg&#8217;, this information
is retrieved from the &#8216;Source&#8217; field.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.PackageRecords.maintainer">
<code class="descname">maintainer</code><a class="headerlink" href="#apt_pkg.PackageRecords.maintainer" title="Permalink to this definition"></a></dt>
<dd><p>Return the maintainer of the package.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.PackageRecords.short_desc">
<code class="descname">short_desc</code><a class="headerlink" href="#apt_pkg.PackageRecords.short_desc" title="Permalink to this definition"></a></dt>
<dd><p>Return the short description. This is the summary on the first line of
the &#8216;Description&#8217; field.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.PackageRecords.long_desc">
<code class="descname">long_desc</code><a class="headerlink" href="#apt_pkg.PackageRecords.long_desc" title="Permalink to this definition"></a></dt>
<dd><p>Return the long description. These are lines 2-END from the
&#8216;Description&#8217; field.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.PackageRecords.name">
<code class="descname">name</code><a class="headerlink" href="#apt_pkg.PackageRecords.name" title="Permalink to this definition"></a></dt>
<dd><p>Return the name of the package. This is the &#8216;Package&#8217; field.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.PackageRecords.homepage">
<code class="descname">homepage</code><a class="headerlink" href="#apt_pkg.PackageRecords.homepage" title="Permalink to this definition"></a></dt>
<dd><p>Return the Homepage. This is the &#8216;Homepage&#8217; field.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.PackageRecords.record">
<code class="descname">record</code><a class="headerlink" href="#apt_pkg.PackageRecords.record" title="Permalink to this definition"></a></dt>
<dd><p>Return the whole record as a string. If you want to access fields of
the record not available as an attribute, you can use
<a class="reference internal" href="#apt_pkg.TagSection" title="apt_pkg.TagSection"><code class="xref py py-class docutils literal"><span class="pre">apt_pkg.TagSection</span></code></a> to parse the record and access the field
name.</p>
<p>Example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">section</span> <span class="o">=</span> <span class="n">apt_pkg</span><span class="o">.</span><span class="n">TagSection</span><span class="p">(</span><span class="n">records</span><span class="o">.</span><span class="n">record</span><span class="p">)</span>
<span class="k">print</span> <span class="n">section</span><span class="p">[</span><span class="s">&#39;SHA256&#39;</span><span class="p">]</span> <span class="c"># Use records.sha256_hash instead</span>
</pre></div>
</div>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="apt_pkg.SourceRecords">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">SourceRecords</code><a class="headerlink" href="#apt_pkg.SourceRecords" title="Permalink to this definition"></a></dt>
<dd><p>Provide an easy way to look up the records of source packages and
provide easy attributes for some widely used fields of the record.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">If the Lookup failed, because no package could be found, no error is
raised. Instead, the attributes listed below are simply not existing
anymore (same applies when no Lookup has been made, or when it has
been restarted).</p>
</div>
<dl class="method">
<dt id="apt_pkg.SourceRecords.lookup">
<code class="descname">lookup</code><span class="sig-paren">(</span><em>pkgname: str</em><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.SourceRecords.lookup" title="Permalink to this definition"></a></dt>
<dd><p>Look up the source package with the given name. Each call moves
the position of the records parser forward. If there are no
more records, return None. If the lookup failed this way,
access to any of the attributes will result in an
<code class="xref py py-exc docutils literal"><span class="pre">AttributeError</span></code>.</p>
<p>Imagine a package P with two versions X, Y. The first <code class="docutils literal"><span class="pre">lookup(P)</span></code>
would set the record to version X and the second <code class="docutils literal"><span class="pre">lookup(P)</span></code> to
version Y. A third call would return <code class="docutils literal"><span class="pre">None</span></code> and access to any
of the below attributes will result in an <code class="xref py py-exc docutils literal"><span class="pre">AttributeError</span></code></p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.SourceRecords.restart">
<code class="descname">restart</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.SourceRecords.restart" title="Permalink to this definition"></a></dt>
<dd><p>Restart the lookup process. This moves the parser to the first
package and lookups can now be made just like on a new object.</p>
<p>Imagine a package P with two versions X, Y. The first <code class="docutils literal"><span class="pre">Lookup(P)</span></code>
would set the record to version X and the second <code class="docutils literal"><span class="pre">Lookup(P)</span></code> to
version Y. If you now call <code class="docutils literal"><span class="pre">restart()</span></code>, the internal position
will be cleared. Now you can call <code class="docutils literal"><span class="pre">lookup(P)</span></code> again to move to X.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.SourceRecords.binaries">
<code class="descname">binaries</code><a class="headerlink" href="#apt_pkg.SourceRecords.binaries" title="Permalink to this definition"></a></dt>
<dd><p>Return a list of strings describing the package names of the binaries
created by the source package. This matches the &#8216;Binary&#8217; field in the
raw record.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.SourceRecords.build_depends">
<code class="descname">build_depends</code><a class="headerlink" href="#apt_pkg.SourceRecords.build_depends" title="Permalink to this definition"></a></dt>
<dd><p>Return a dictionary representing the build-time dependencies of the
package. The format is the same as for <a class="reference internal" href="#apt_pkg.Version.depends_list_str" title="apt_pkg.Version.depends_list_str"><code class="xref py py-attr docutils literal"><span class="pre">Version.depends_list_str</span></code></a>
and possible keys being <code class="docutils literal"><span class="pre">&quot;Build-Depends&quot;</span></code>, <code class="docutils literal"><span class="pre">&quot;Build-Depends-Indep&quot;</span></code>,
<code class="docutils literal"><span class="pre">&quot;Build-Conflicts&quot;</span></code> or <code class="docutils literal"><span class="pre">&quot;Build-Conflicts-Indep&quot;</span></code>.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.SourceRecords.files">
<code class="descname">files</code><a class="headerlink" href="#apt_pkg.SourceRecords.files" title="Permalink to this definition"></a></dt>
<dd><p>The list of files. This returns a list of tuples with the contents
<code class="docutils literal"><span class="pre">(str:</span> <span class="pre">md5,</span> <span class="pre">int:</span> <span class="pre">size,</span> <span class="pre">str:</span> <span class="pre">path,</span> <span class="pre">str:type)</span></code>, where
&#8216;type&#8217; can be &#8216;diff&#8217; (includes .debian.tar.gz), &#8216;dsc&#8217;, &#8216;tar&#8217;.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.SourceRecords.index">
<code class="descname">index</code><a class="headerlink" href="#apt_pkg.SourceRecords.index" title="Permalink to this definition"></a></dt>
<dd><p>A list of <a class="reference internal" href="#apt_pkg.IndexFile" title="apt_pkg.IndexFile"><code class="xref py py-class docutils literal"><span class="pre">IndexFile</span></code></a> objects associated with this
source package record.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.SourceRecords.maintainer">
<code class="descname">maintainer</code><a class="headerlink" href="#apt_pkg.SourceRecords.maintainer" title="Permalink to this definition"></a></dt>
<dd><p>A string describing the name of the maintainer.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.SourceRecords.package">
<code class="descname">package</code><a class="headerlink" href="#apt_pkg.SourceRecords.package" title="Permalink to this definition"></a></dt>
<dd><p>The name of the source package.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.SourceRecords.record">
<code class="descname">record</code><a class="headerlink" href="#apt_pkg.SourceRecords.record" title="Permalink to this definition"></a></dt>
<dd><p>The whole record, as a string. You can use <code class="xref py py-func docutils literal"><span class="pre">apt_pkg.ParseSection()</span></code>
if you need to parse it. You need to parse the record  to access
fields not available via the attributes such as &#8216;Standards-Version&#8217;</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.SourceRecords.section">
<code class="descname">section</code><a class="headerlink" href="#apt_pkg.SourceRecords.section" title="Permalink to this definition"></a></dt>
<dd><p>A string describing the section.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.SourceRecords.version">
<code class="descname">version</code><a class="headerlink" href="#apt_pkg.SourceRecords.version" title="Permalink to this definition"></a></dt>
<dd><p>A string describing the version of the source package.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="the-acquire-interface">
<h2>The Acquire interface<a class="headerlink" href="#the-acquire-interface" title="Permalink to this headline"></a></h2>
<p>The Acquire Interface is responsible for all sorts of downloading in apt. All
packages, index files, etc. downloading is done using the Acquire functionality.</p>
<p>The <a class="reference internal" href="#module-apt_pkg" title="apt_pkg"><code class="xref py py-mod docutils literal"><span class="pre">apt_pkg</span></code></a> module provides a subset of this functionality which allows
you to implement file downloading in your applications. Together with the
<a class="reference internal" href="#apt_pkg.PackageManager" title="apt_pkg.PackageManager"><code class="xref py py-class docutils literal"><span class="pre">PackageManager</span></code></a> class you can also fetch all the packages marked for
installation.</p>
<dl class="class">
<dt id="apt_pkg.Acquire">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">Acquire</code><span class="sig-paren">(</span><span class="optional">[</span><em>progress: apt.progress.base.AcquireProgress</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.Acquire" title="Permalink to this definition"></a></dt>
<dd><p>Coordinate the retrieval of files via network or local file system
(using <code class="docutils literal"><span class="pre">copy://path/to/file</span></code> style URIs). Items can be added to
an Acquire object using various means such as creating instances
of <a class="reference internal" href="#apt_pkg.AcquireFile" title="apt_pkg.AcquireFile"><code class="xref py py-class docutils literal"><span class="pre">AcquireFile</span></code></a> or the methods <a class="reference internal" href="#apt_pkg.SourceList.get_indexes" title="apt_pkg.SourceList.get_indexes"><code class="xref py py-meth docutils literal"><span class="pre">SourceList.get_indexes()</span></code></a>
and <a class="reference internal" href="#apt_pkg.PackageManager.get_archives" title="apt_pkg.PackageManager.get_archives"><code class="xref py py-meth docutils literal"><span class="pre">PackageManager.get_archives()</span></code></a>.</p>
<p>Acquire objects maintain a list of items which will be fetched or have
been fetched already during the lifetime of this object. To add new items
to this list, you can create new <a class="reference internal" href="#apt_pkg.AcquireFile" title="apt_pkg.AcquireFile"><code class="xref py py-class docutils literal"><span class="pre">AcquireFile</span></code></a> objects which allow
you to add single files.</p>
<p>The constructor takes an optional parameter <em>progress</em> which takes an
<a class="reference internal" href="apt.progress.base.html#apt.progress.base.AcquireProgress" title="apt.progress.base.AcquireProgress"><code class="xref py py-class docutils literal"><span class="pre">apt.progress.base.AcquireProgress</span></code></a> object. This object may then
report progress information (see <a class="reference internal" href="apt.progress.text.html#module-apt.progress.text" title="apt.progress.text"><code class="xref py py-mod docutils literal"><span class="pre">apt.progress.text</span></code></a> for reporting
progress to a I/O stream).</p>
<p>Acquire items have two methods to start and stop the fetching:</p>
<dl class="method">
<dt id="apt_pkg.Acquire.run">
<code class="descname">run</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &rarr; int<a class="headerlink" href="#apt_pkg.Acquire.run" title="Permalink to this definition"></a></dt>
<dd><p>Fetch all the items which have been added by <a class="reference internal" href="#apt_pkg.AcquireFile" title="apt_pkg.AcquireFile"><code class="xref py py-class docutils literal"><span class="pre">AcquireFile</span></code></a> and
return one of the constants <a class="reference internal" href="#apt_pkg.Acquire.RESULT_CANCELLED" title="apt_pkg.Acquire.RESULT_CANCELLED"><code class="xref py py-attr docutils literal"><span class="pre">RESULT_CANCELLED</span></code></a>,
<a class="reference internal" href="#apt_pkg.Acquire.RESULT_CONTINUE" title="apt_pkg.Acquire.RESULT_CONTINUE"><code class="xref py py-attr docutils literal"><span class="pre">RESULT_CONTINUE</span></code></a>, <a class="reference internal" href="#apt_pkg.Acquire.RESULT_FAILED" title="apt_pkg.Acquire.RESULT_FAILED"><code class="xref py py-attr docutils literal"><span class="pre">RESULT_FAILED</span></code></a> to describe the
result of the run.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.Acquire.shutdown">
<code class="descname">shutdown</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.Acquire.shutdown" title="Permalink to this definition"></a></dt>
<dd><p>Shut the fetcher down. This removes all items from the queue and
makes all <a class="reference internal" href="#apt_pkg.AcquireItem" title="apt_pkg.AcquireItem"><code class="xref py py-class docutils literal"><span class="pre">AcquireItem</span></code></a>, <a class="reference internal" href="#apt_pkg.AcquireWorker" title="apt_pkg.AcquireWorker"><code class="xref py py-class docutils literal"><span class="pre">AcquireWorker</span></code></a>,
<a class="reference internal" href="#apt_pkg.AcquireItemDesc" title="apt_pkg.AcquireItemDesc"><code class="xref py py-class docutils literal"><span class="pre">AcquireItemDesc</span></code></a> objects useless. Accessing an object of one
of those types can cause a segfault then.</p>
<p>Removing an item does not mean that the already fetched data will
be removed from the destination. Instead, APT might use the partial
result and continue from thereon.</p>
</dd></dl>

<p>Furthermore, they provide three attributes which provide information
on how much data is already available and how much data still needs
to be fetched:</p>
<dl class="attribute">
<dt id="apt_pkg.Acquire.fetch_needed">
<code class="descname">fetch_needed</code><a class="headerlink" href="#apt_pkg.Acquire.fetch_needed" title="Permalink to this definition"></a></dt>
<dd><p>The amount of data that has to be fetched in order to fetch all
queued items.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Acquire.partial_present">
<code class="descname">partial_present</code><a class="headerlink" href="#apt_pkg.Acquire.partial_present" title="Permalink to this definition"></a></dt>
<dd><p>The amount of data which is already available.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Acquire.total_needed">
<code class="descname">total_needed</code><a class="headerlink" href="#apt_pkg.Acquire.total_needed" title="Permalink to this definition"></a></dt>
<dd><p>The total amount of bytes needed (including those of files which are
already present).</p>
</dd></dl>

<p>They also provide two attributes representing the items being processed
and the workers fetching them:</p>
<dl class="attribute">
<dt id="apt_pkg.Acquire.items">
<code class="descname">items</code><a class="headerlink" href="#apt_pkg.Acquire.items" title="Permalink to this definition"></a></dt>
<dd><p>A list of <a class="reference internal" href="#apt_pkg.AcquireItem" title="apt_pkg.AcquireItem"><code class="xref py py-class docutils literal"><span class="pre">AcquireItem</span></code></a> objects which are attached to the
to this Acquire object. This includes all items ever attached to
this object (except if they were removed using, for example,
<a class="reference internal" href="#apt_pkg.Acquire.shutdown" title="apt_pkg.Acquire.shutdown"><code class="xref py py-meth docutils literal"><span class="pre">shutdown()</span></code></a> or by deleting an <a class="reference internal" href="#apt_pkg.AcquireFile" title="apt_pkg.AcquireFile"><code class="xref py py-class docutils literal"><span class="pre">AcquireFile</span></code></a> object.)</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Acquire.workers">
<code class="descname">workers</code><a class="headerlink" href="#apt_pkg.Acquire.workers" title="Permalink to this definition"></a></dt>
<dd><p>A list of <a class="reference internal" href="#apt_pkg.AcquireWorker" title="apt_pkg.AcquireWorker"><code class="xref py py-class docutils literal"><span class="pre">AcquireWorker</span></code></a> objects which are currently active
on this instance.</p>
</dd></dl>

<p>The Acquire class comes with three constants which represents the results
of the <a class="reference internal" href="#apt_pkg.Acquire.run" title="apt_pkg.Acquire.run"><code class="xref py py-meth docutils literal"><span class="pre">run()</span></code></a> method:</p>
<dl class="attribute">
<dt id="apt_pkg.Acquire.RESULT_CANCELLED">
<code class="descname">RESULT_CANCELLED</code><a class="headerlink" href="#apt_pkg.Acquire.RESULT_CANCELLED" title="Permalink to this definition"></a></dt>
<dd><p>The fetching has been aborted, e.g. due to a progress class returning
<code class="docutils literal"><span class="pre">False</span></code> in its <code class="xref py py-meth docutils literal"><span class="pre">pulse()</span></code> method.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Acquire.RESULT_CONTINUE">
<code class="descname">RESULT_CONTINUE</code><a class="headerlink" href="#apt_pkg.Acquire.RESULT_CONTINUE" title="Permalink to this definition"></a></dt>
<dd><p>All items have been fetched successfully or failed transiently
and the process has not been canceled.</p>
<p>You need to look at the status of each item and check if it has not
failed transiently to discover errors like a Not Found when acquiring
packages.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Acquire.RESULT_FAILED">
<code class="descname">RESULT_FAILED</code><a class="headerlink" href="#apt_pkg.Acquire.RESULT_FAILED" title="Permalink to this definition"></a></dt>
<dd><p>An item failed to fetch due to some reasons.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="apt_pkg.AcquireItem">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">AcquireItem</code><a class="headerlink" href="#apt_pkg.AcquireItem" title="Permalink to this definition"></a></dt>
<dd><p>An AcquireItem object represents a single item of an <a class="reference internal" href="#apt_pkg.Acquire" title="apt_pkg.Acquire"><code class="xref py py-class docutils literal"><span class="pre">Acquire</span></code></a>
object. It is an abstract class to represent various types of items
which are implemented as subclasses. The only exported subclass is
<a class="reference internal" href="#apt_pkg.AcquireFile" title="apt_pkg.AcquireFile"><code class="xref py py-class docutils literal"><span class="pre">AcquireFile</span></code></a> which can be used to fetch files.</p>
<dl class="attribute">
<dt id="apt_pkg.AcquireItem.complete">
<code class="descname">complete</code><a class="headerlink" href="#apt_pkg.AcquireItem.complete" title="Permalink to this definition"></a></dt>
<dd><p>A boolean value which is True only if the item has been
fetched successfully.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.AcquireItem.desc_uri">
<code class="descname">desc_uri</code><a class="headerlink" href="#apt_pkg.AcquireItem.desc_uri" title="Permalink to this definition"></a></dt>
<dd><p>An URI describing where the item is located at.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.AcquireItem.destfile">
<code class="descname">destfile</code><a class="headerlink" href="#apt_pkg.AcquireItem.destfile" title="Permalink to this definition"></a></dt>
<dd><p>The path to the local location where the fetched data will be
stored at.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.AcquireItem.error_text">
<code class="descname">error_text</code><a class="headerlink" href="#apt_pkg.AcquireItem.error_text" title="Permalink to this definition"></a></dt>
<dd><p>The error message. For example, when a file does not exist on a HTTP
server, this will contain a 404 error message.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.AcquireItem.filesize">
<code class="descname">filesize</code><a class="headerlink" href="#apt_pkg.AcquireItem.filesize" title="Permalink to this definition"></a></dt>
<dd><p>The size of the file, in bytes. If the size of the to be fetched file
is unknown, this attribute is set to <code class="docutils literal"><span class="pre">0</span></code>.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.AcquireItem.id">
<code class="descname">id</code><a class="headerlink" href="#apt_pkg.AcquireItem.id" title="Permalink to this definition"></a></dt>
<dd><p>The ID of the item. This attribute is normally set to <code class="docutils literal"><span class="pre">0</span></code>, users may
set a custom value here, for instance in an overridden
<a class="reference internal" href="apt.progress.base.html#apt.progress.base.AcquireProgress.fetch" title="apt.progress.base.AcquireProgress.fetch"><code class="xref py py-meth docutils literal"><span class="pre">apt.progress.base.AcquireProgress.fetch()</span></code></a> method (the progress
class could keep a counter, increase it by one for every <code class="xref py py-meth docutils literal"><span class="pre">fetch()</span></code>
call and assign the current value to this attribute).</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.AcquireItem.is_trusted">
<code class="descname">is_trusted</code><a class="headerlink" href="#apt_pkg.AcquireItem.is_trusted" title="Permalink to this definition"></a></dt>
<dd><p>A boolean value determining whether the file is trusted. Only <code class="docutils literal"><span class="pre">True</span></code>
if the item represents a package coming from a repository which is
signed by one of the keys in APT&#8217;s keyring.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.AcquireItem.local">
<code class="descname">local</code><a class="headerlink" href="#apt_pkg.AcquireItem.local" title="Permalink to this definition"></a></dt>
<dd><p>A boolean value determining whether this file is locally available
(<code class="docutils literal"><span class="pre">True</span></code>) or whether it has to be fetched from a remote source
(<code class="docutils literal"><span class="pre">False</span></code>).</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.AcquireItem.mode">
<code class="descname">mode</code><a class="headerlink" href="#apt_pkg.AcquireItem.mode" title="Permalink to this definition"></a></dt>
<dd><p>Old name for active_subprocess</p>
<div class="deprecated">
<p><span class="versionmodified">Deprecated since version 1.0.</span></p>
</div>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.AcquireItem.active_subprocess">
<code class="descname">active_subprocess</code><a class="headerlink" href="#apt_pkg.AcquireItem.active_subprocess" title="Permalink to this definition"></a></dt>
<dd><p>The name of the active subprocess (for instance, &#8216;gzip&#8217;, &#8216;rred&#8217; or &#8216;gpgv&#8217;).</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 1.0.</span></p>
</div>
</dd></dl>

<p><strong>Status</strong>:</p>
<p>The following attribute represents the status of the item. This class
provides several constants for comparing against this value which are
listed here as well.</p>
<dl class="attribute">
<dt id="apt_pkg.AcquireItem.status">
<code class="descname">status</code><a class="headerlink" href="#apt_pkg.AcquireItem.status" title="Permalink to this definition"></a></dt>
<dd><p>Integer, representing the status of the item. This attribute can be
compared against the following constants to gain useful information
on the item&#8217;s status.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.AcquireItem.STAT_AUTH_ERROR">
<code class="descname">STAT_AUTH_ERROR</code><a class="headerlink" href="#apt_pkg.AcquireItem.STAT_AUTH_ERROR" title="Permalink to this definition"></a></dt>
<dd><p>An authentication error occurred while trying to fetch the item.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.AcquireItem.STAT_DONE">
<code class="descname">STAT_DONE</code><a class="headerlink" href="#apt_pkg.AcquireItem.STAT_DONE" title="Permalink to this definition"></a></dt>
<dd><p>The item is completely fetched and there have been no problems
while fetching the item.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.AcquireItem.STAT_ERROR">
<code class="descname">STAT_ERROR</code><a class="headerlink" href="#apt_pkg.AcquireItem.STAT_ERROR" title="Permalink to this definition"></a></dt>
<dd><p>An error occurred while trying to fetch the item. This error is
normally not related to authentication problems, as thus are
dealt with using <a class="reference internal" href="#apt_pkg.AcquireItem.STAT_AUTH_ERROR" title="apt_pkg.AcquireItem.STAT_AUTH_ERROR"><code class="xref py py-attr docutils literal"><span class="pre">STAT_AUTH_ERROR</span></code></a>.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.AcquireItem.STAT_FETCHING">
<code class="descname">STAT_FETCHING</code><a class="headerlink" href="#apt_pkg.AcquireItem.STAT_FETCHING" title="Permalink to this definition"></a></dt>
<dd><p>The item is being fetched currently.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.AcquireItem.STAT_IDLE">
<code class="descname">STAT_IDLE</code><a class="headerlink" href="#apt_pkg.AcquireItem.STAT_IDLE" title="Permalink to this definition"></a></dt>
<dd><p>The item is yet to be fetched.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.AcquireItem.STAT_TRANSIENT_NETWORK_ERROR">
<code class="descname">STAT_TRANSIENT_NETWORK_ERROR</code><a class="headerlink" href="#apt_pkg.AcquireItem.STAT_TRANSIENT_NETWORK_ERROR" title="Permalink to this definition"></a></dt>
<dd><p>There was a network error.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="apt_pkg.AcquireFile">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">AcquireFile</code><span class="sig-paren">(</span><em>owner</em>, <em>uri</em><span class="optional">[</span>, <em>hash</em>, <em>size</em>, <em>descr</em>, <em>short_descr</em>, <em>destdir</em>, <em>destfile</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.AcquireFile" title="Permalink to this definition"></a></dt>
<dd><p>Create a new <a class="reference internal" href="#apt_pkg.AcquireFile" title="apt_pkg.AcquireFile"><code class="xref py py-class docutils literal"><span class="pre">AcquireFile()</span></code></a> object and register it with <em>acquire</em>,
so it will be fetched. You must always keep around a reference to the
object, otherwise it will be removed from the Acquire queue again.</p>
<p>The parameter <em>owner</em> refers to an <a class="reference internal" href="#apt_pkg.Acquire" title="apt_pkg.Acquire"><code class="xref py py-class docutils literal"><span class="pre">Acquire()</span></code></a> object as returned
by <code class="xref py py-func docutils literal"><span class="pre">GetAcquire()</span></code>. The file will be added to the Acquire queue
automatically.</p>
<p>The parameter <em>uri</em> refers to the location of the file, any protocol
of apt is supported.</p>
<p>The parameter <em>hash</em> refers to the hash of the file. If this is set
libapt will check the file after downloading. See <a class="reference internal" href="#apt_pkg.HashString" title="apt_pkg.HashString"><code class="xref py py-class docutils literal"><span class="pre">HashString</span></code></a>
for the combined form string format description.</p>
<p>The parameter <em>size</em> can be used to specify the size of the package,
which can then be used to calculate the progress and validate the download.</p>
<p>The parameter <em>descr</em> is a description of the download. It may be
used to describe the item in the progress class. <em>short_descr</em> is the
short form of it.</p>
<p>The parameters <em>descr</em> and <em>short_descr</em> can be used to specify
descriptions for the item. The string passed to <em>descr</em> should
describe the file and its origin (e.g. &#8220;<a class="reference external" href="http://localhost">http://localhost</a> sid/main
python-apt 0.7.94.2&#8221;) and the string passed to <em>short_descr</em> should
be one word such as the name of a package.</p>
<p>Normally, the file will be stored in the current directory using the
file name given in the URI. This directory can be changed by passing
the name of a directory to the <em>destdir</em> parameter. It is also possible
to set a path to a file using the <em>destfile</em> parameter, but both can
not be specified together.</p>
<p>In terms of attributes, this class is a subclass of <a class="reference internal" href="#apt_pkg.AcquireItem" title="apt_pkg.AcquireItem"><code class="xref py py-class docutils literal"><span class="pre">AcquireItem</span></code></a>
and thus inherits all its attributes.</p>
</dd></dl>

<dl class="class">
<dt id="apt_pkg.AcquireWorker">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">AcquireWorker</code><a class="headerlink" href="#apt_pkg.AcquireWorker" title="Permalink to this definition"></a></dt>
<dd><p>An <a class="reference internal" href="#apt_pkg.AcquireWorker" title="apt_pkg.AcquireWorker"><code class="xref py py-class docutils literal"><span class="pre">AcquireWorker</span></code></a> object represents a sub-process responsible for
fetching files from remote locations. There is no possibility to create
instances of this class from within Python, but a list of objects of
currently active workers is provided by <a class="reference internal" href="#apt_pkg.Acquire.workers" title="apt_pkg.Acquire.workers"><code class="xref py py-attr docutils literal"><span class="pre">Acquire.workers</span></code></a>.</p>
<p>Objects of this type provide several attributes which give information
about the worker&#8217;s current activity.</p>
<dl class="attribute">
<dt id="apt_pkg.AcquireWorker.current_item">
<code class="descname">current_item</code><a class="headerlink" href="#apt_pkg.AcquireWorker.current_item" title="Permalink to this definition"></a></dt>
<dd><p>The item which is currently being fetched. This returns an
<a class="reference internal" href="#apt_pkg.AcquireItemDesc" title="apt_pkg.AcquireItemDesc"><code class="xref py py-class docutils literal"><span class="pre">AcquireItemDesc</span></code></a> object.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.AcquireWorker.current_size">
<code class="descname">current_size</code><a class="headerlink" href="#apt_pkg.AcquireWorker.current_size" title="Permalink to this definition"></a></dt>
<dd><p>How many bytes of the file have been downloaded. Zero if the current
progress of the file cannot be determined.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.AcquireWorker.resumepoint">
<code class="descname">resumepoint</code><a class="headerlink" href="#apt_pkg.AcquireWorker.resumepoint" title="Permalink to this definition"></a></dt>
<dd><p>The amount of data which was already available when the download was
started.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.AcquireWorker.status">
<code class="descname">status</code><a class="headerlink" href="#apt_pkg.AcquireWorker.status" title="Permalink to this definition"></a></dt>
<dd><p>The most recent (localized) status string received from the
sub-process.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.AcquireWorker.total_size">
<code class="descname">total_size</code><a class="headerlink" href="#apt_pkg.AcquireWorker.total_size" title="Permalink to this definition"></a></dt>
<dd><p>The total number of bytes to be downloaded for the item. Zero if the
total size is unknown.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="apt_pkg.AcquireItemDesc">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">AcquireItemDesc</code><a class="headerlink" href="#apt_pkg.AcquireItemDesc" title="Permalink to this definition"></a></dt>
<dd><p>An <a class="reference internal" href="#apt_pkg.AcquireItemDesc" title="apt_pkg.AcquireItemDesc"><code class="xref py py-class docutils literal"><span class="pre">AcquireItemDesc</span></code></a> object stores information about the item which
can be used to describe the item. Objects of this class are used in the
progress classes, see the <a class="reference internal" href="apt.progress.base.html#apt.progress.base.AcquireProgress" title="apt.progress.base.AcquireProgress"><code class="xref py py-class docutils literal"><span class="pre">apt.progress.base.AcquireProgress</span></code></a>
documentation for information how.</p>
<dl class="attribute">
<dt id="apt_pkg.AcquireItemDesc.description">
<code class="descname">description</code><a class="headerlink" href="#apt_pkg.AcquireItemDesc.description" title="Permalink to this definition"></a></dt>
<dd><p>The long description given to the item.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.AcquireItemDesc.owner">
<code class="descname">owner</code><a class="headerlink" href="#apt_pkg.AcquireItemDesc.owner" title="Permalink to this definition"></a></dt>
<dd><p>The <a class="reference internal" href="#apt_pkg.AcquireItem" title="apt_pkg.AcquireItem"><code class="xref py py-class docutils literal"><span class="pre">AcquireItem</span></code></a> object owning this object.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.AcquireItemDesc.shortdesc">
<code class="descname">shortdesc</code><a class="headerlink" href="#apt_pkg.AcquireItemDesc.shortdesc" title="Permalink to this definition"></a></dt>
<dd><p>A short description which has been given to this item.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.AcquireItemDesc.uri">
<code class="descname">uri</code><a class="headerlink" href="#apt_pkg.AcquireItemDesc.uri" title="Permalink to this definition"></a></dt>
<dd><p>The URI from which this item would be downloaded.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="hashes">
<h2>Hashes<a class="headerlink" href="#hashes" title="Permalink to this headline"></a></h2>
<p>The apt_pkg module also provides several hash functions. If you develop
applications with python-apt it is often easier to use these functions instead
of the ones provides in Python&#8217;s <code class="xref py py-mod docutils literal"><span class="pre">hashlib</span></code> module.</p>
<p>The module provides the two classes <a class="reference internal" href="#apt_pkg.Hashes" title="apt_pkg.Hashes"><code class="xref py py-class docutils literal"><span class="pre">Hashes</span></code></a> and <a class="reference internal" href="#apt_pkg.HashString" title="apt_pkg.HashString"><code class="xref py py-class docutils literal"><span class="pre">HashString</span></code></a> for
generic hash support:</p>
<dl class="class">
<dt id="apt_pkg.Hashes">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">Hashes</code><span class="sig-paren">(</span><em>object</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.Hashes" title="Permalink to this definition"></a></dt>
<dd><p>Calculate all supported hashes of the object. <em>object</em> may either be a
string, in which cases the hashes of the string are calculated; or a
<code class="xref py py-class docutils literal"><span class="pre">file()</span></code> object or file descriptor, in which case the hashes of
its contents is calculated. The calculated hashes are then available via
attributes:</p>
<dl class="attribute">
<dt id="apt_pkg.Hashes.md5">
<code class="descname">md5</code><a class="headerlink" href="#apt_pkg.Hashes.md5" title="Permalink to this definition"></a></dt>
<dd><p>The MD5 hash of the data, as string.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Hashes.sha1">
<code class="descname">sha1</code><a class="headerlink" href="#apt_pkg.Hashes.sha1" title="Permalink to this definition"></a></dt>
<dd><p>The SHA1 hash of the data, as string.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.Hashes.sha256">
<code class="descname">sha256</code><a class="headerlink" href="#apt_pkg.Hashes.sha256" title="Permalink to this definition"></a></dt>
<dd><p>The SHA256 hash of the data, as string.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="apt_pkg.HashString">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">HashString</code><span class="sig-paren">(</span><em>type: str</em><span class="optional">[</span>, <em>hash: str</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.HashString" title="Permalink to this definition"></a></dt>
<dd><p>HashString objects store the type of a hash and the corresponding hash.
They are used by e.g <a class="reference internal" href="#apt_pkg.IndexRecords.lookup" title="apt_pkg.IndexRecords.lookup"><code class="xref py py-meth docutils literal"><span class="pre">IndexRecords.lookup()</span></code></a>. The first parameter,
<em>type</em> refers to one of &#8220;MD5Sum&#8221;, &#8220;SHA1&#8221; and &#8220;SHA256&#8221;. The second parameter
<em>hash</em> is the corresponding hash.</p>
<p>You can also use a combined form by passing a string with type and hash
separated by a colon as the only argument. For example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">HashString</span><span class="p">(</span><span class="s">&quot;MD5Sum:d41d8cd98f00b204e9800998ecf8427e&quot;</span><span class="p">)</span>
</pre></div>
</div>
<dl class="describe">
<dt>
<code class="descname">str(hashstring)</code></dt>
<dd><p>Convert the HashString to a string by joining the hash type and the
hash using &#8216;:&#8217;, e.g. <code class="docutils literal"><span class="pre">&quot;MD5Sum:d41d8cd98f00b204e9800998ecf8427e&quot;</span></code>.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.HashString.hashtype">
<code class="descname">hashtype</code><a class="headerlink" href="#apt_pkg.HashString.hashtype" title="Permalink to this definition"></a></dt>
<dd><p>The type of the hash, as a string. This may be &#8220;MD5Sum&#8221;, &#8220;SHA1&#8221;,
&#8220;SHA256&#8221; or &#8220;SHA512&#8221;.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.HashString.verify_file">
<code class="descname">verify_file</code><span class="sig-paren">(</span><em>filename: str</em><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.HashString.verify_file" title="Permalink to this definition"></a></dt>
<dd><p>Verify that the file given by the parameter <em>filename</em> matches the
hash stored in this object.</p>
</dd></dl>

</dd></dl>

<p>The <a class="reference internal" href="#module-apt_pkg" title="apt_pkg"><code class="xref py py-mod docutils literal"><span class="pre">apt_pkg</span></code></a> module also provides the functions <a class="reference internal" href="#apt_pkg.md5sum" title="apt_pkg.md5sum"><code class="xref py py-func docutils literal"><span class="pre">md5sum()</span></code></a>,
<a class="reference internal" href="#apt_pkg.sha1sum" title="apt_pkg.sha1sum"><code class="xref py py-func docutils literal"><span class="pre">sha1sum()</span></code></a> and <a class="reference internal" href="#apt_pkg.sha256sum" title="apt_pkg.sha256sum"><code class="xref py py-func docutils literal"><span class="pre">sha256sum()</span></code></a> for creating a single hash from a
<code class="xref py py-class docutils literal"><span class="pre">bytes</span></code> or <code class="xref py py-class docutils literal"><span class="pre">file</span></code> object:</p>
<dl class="function">
<dt id="apt_pkg.md5sum">
<code class="descclassname">apt_pkg.</code><code class="descname">md5sum</code><span class="sig-paren">(</span><em>object</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.md5sum" title="Permalink to this definition"></a></dt>
<dd><p>Return the md5sum of the object. <em>object</em> may either be a string, in
which case the md5sum of the string is returned, or a <code class="xref py py-class docutils literal"><span class="pre">file()</span></code>
object (or a file descriptor), in which case the md5sum of its contents is
returned.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.7.100: </span>Added support for using file descriptors.</p>
</div>
</dd></dl>

<dl class="function">
<dt id="apt_pkg.sha1sum">
<code class="descclassname">apt_pkg.</code><code class="descname">sha1sum</code><span class="sig-paren">(</span><em>object</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.sha1sum" title="Permalink to this definition"></a></dt>
<dd><p>Return the sha1sum of the object. <em>object</em> may either be a string, in
which case the sha1sum of the string is returned, or a <code class="xref py py-class docutils literal"><span class="pre">file()</span></code>
object (or a file descriptor), in which case the sha1sum of its contents
is returned.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.7.100: </span>Added support for using file descriptors.</p>
</div>
</dd></dl>

<dl class="function">
<dt id="apt_pkg.sha256sum">
<code class="descclassname">apt_pkg.</code><code class="descname">sha256sum</code><span class="sig-paren">(</span><em>object</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.sha256sum" title="Permalink to this definition"></a></dt>
<dd><p>Return the sha256sum of the object. <em>object</em> may either be a string, in
which case the sha256sum of the string is returned, or a <code class="xref py py-class docutils literal"><span class="pre">file()</span></code>
object  (or a file descriptor), in which case the sha256sum of its contents
is returned.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.7.100: </span>Added support for using file descriptors.</p>
</div>
</dd></dl>

</div>
<div class="section" id="debian-control-files">
<h2>Debian control files<a class="headerlink" href="#debian-control-files" title="Permalink to this headline"></a></h2>
<p>Debian control files are files containing multiple stanzas of <span class="target" id="index-0"></span><a class="rfc reference external" href="https://tools.ietf.org/html/rfc822.html"><strong>RFC 822</strong></a>-style
header sections. They are widely used in the Debian community, and can represent
many kinds of information. One example for such a file is the
<code class="file docutils literal"><span class="pre">/var/lib/dpkg/status</span></code> file which contains a list of the currently
installed packages.</p>
<p>The <a class="reference internal" href="#module-apt_pkg" title="apt_pkg"><code class="xref py py-mod docutils literal"><span class="pre">apt_pkg</span></code></a> module provides two classes to read those files and parts
thereof and provides a function <code class="xref py py-func docutils literal"><span class="pre">RewriteSection()</span></code> which takes a
<a class="reference internal" href="#apt_pkg.TagSection" title="apt_pkg.TagSection"><code class="xref py py-class docutils literal"><span class="pre">TagSection()</span></code></a> object and sorting information and outputs a sorted
section as a string.</p>
<dl class="class">
<dt id="apt_pkg.TagFile">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">TagFile</code><span class="sig-paren">(</span><em>file</em>, <em>bytes: bool = False</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.TagFile" title="Permalink to this definition"></a></dt>
<dd><p>An object which represents a typical debian control file. Can be used for
Packages, Sources, control, Release, etc.</p>
<p>The <em>file</em> argument shall be a path name or an open file object. The
argument <em>bytes</em> specifies whether the file shall be represented using
bytes (<code class="docutils literal"><span class="pre">True</span></code>) or unicode (<code class="docutils literal"><span class="pre">False</span></code>) strings.</p>
<p>It is a context manager that can be used with a with statement or the
<a class="reference internal" href="#apt_pkg.TagFile.close" title="apt_pkg.TagFile.close"><code class="xref py py-meth docutils literal"><span class="pre">close()</span></code></a> method.</p>
<dl class="describe">
<dt>
<code class="descname">with TagFile(...) as ...:</code></dt>
<dd><p>Use the <a class="reference internal" href="#apt_pkg.TagFile" title="apt_pkg.TagFile"><code class="xref py py-class docutils literal"><span class="pre">TagFile</span></code></a> as a context manager. This will automatically
close the file after the body finished execution.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 1.0.</span></p>
</div>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.TagFile.close">
<code class="descname">close</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.TagFile.close" title="Permalink to this definition"></a></dt>
<dd><p>Close the file. It&#8217;s recommended to use the context manager
instead (that is, the <cite>with</cite> statement).</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 1.0.</span></p>
</div>
</dd></dl>

<p>It provides two kinds of API which should not be used together:</p>
<p>The first API implements the iterator protocol and should be used whenever
possible because it has less side effects than the other one. It may be
used e.g. with a for loop:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">with</span> <span class="n">apt_pkg</span><span class="o">.</span><span class="n">TagFile</span><span class="p">(</span><span class="s">&#39;/var/lib/dpkg/status&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">tagfile</span><span class="p">:</span>
    <span class="k">for</span> <span class="n">section</span> <span class="ow">in</span> <span class="n">tagfile</span><span class="p">:</span>
        <span class="k">print</span> <span class="n">section</span><span class="p">[</span><span class="s">&#39;Package&#39;</span><span class="p">]</span>
</pre></div>
</div>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.7.100: </span>Added support for using gzip files, via <code class="xref py py-class docutils literal"><span class="pre">gzip.GzipFile</span></code> or any
file containing a compressed gzip stream.</p>
</div>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.8.5: </span>Added support for using bytes instead of str in Python 3</p>
</div>
<dl class="method">
<dt id="apt_pkg.TagFile.next">
<code class="descname">next</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.TagFile.next" title="Permalink to this definition"></a></dt>
<dd><p>A TagFile is its own iterator. This method is part of the iterator
protocol and returns a <a class="reference internal" href="#apt_pkg.TagSection" title="apt_pkg.TagSection"><code class="xref py py-class docutils literal"><span class="pre">TagSection</span></code></a> object for the next
section in the file. If there is no further section, this method
raises the <code class="xref py py-exc docutils literal"><span class="pre">StopIteration</span></code> exception.</p>
<p>From Python 3 on, this method is not available anymore, and the
global function <code class="docutils literal"><span class="pre">next()</span></code> replaces it.</p>
</dd></dl>

<p>The second API uses a shared <a class="reference internal" href="#apt_pkg.TagSection" title="apt_pkg.TagSection"><code class="xref py py-class docutils literal"><span class="pre">TagSection</span></code></a> object which is exposed
through the <a class="reference internal" href="#apt_pkg.section" title="apt_pkg.section"><code class="xref py py-attr docutils literal"><span class="pre">section</span></code></a> attribute. This object is modified by calls
to <a class="reference internal" href="#apt_pkg.TagFile.step" title="apt_pkg.TagFile.step"><code class="xref py py-meth docutils literal"><span class="pre">step()</span></code></a> and <a class="reference internal" href="#apt_pkg.TagFile.jump" title="apt_pkg.TagFile.jump"><code class="xref py py-meth docutils literal"><span class="pre">jump()</span></code></a>. This API provides more control and may
use less memory, but is not recommended because it works by modifying
one object. It can be used like this:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">with</span> <span class="n">apt_pkg</span><span class="o">.</span><span class="n">TagFile</span><span class="p">(</span><span class="s">&#39;/var/lib/dpkg/status&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">tagf</span><span class="p">:</span>
    <span class="n">tagf</span><span class="o">.</span><span class="n">step</span><span class="p">()</span>
    <span class="k">print</span> <span class="n">tagf</span><span class="o">.</span><span class="n">section</span><span class="p">[</span><span class="s">&#39;Package&#39;</span><span class="p">]</span>
</pre></div>
</div>
<dl class="method">
<dt id="apt_pkg.TagFile.step">
<code class="descname">step</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.TagFile.step" title="Permalink to this definition"></a></dt>
<dd><p>Step forward to the next section. This simply returns <code class="docutils literal"><span class="pre">True</span></code> if OK,
and <code class="docutils literal"><span class="pre">False</span></code> if there is no section.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.TagFile.offset">
<code class="descname">offset</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &rarr; int<a class="headerlink" href="#apt_pkg.TagFile.offset" title="Permalink to this definition"></a></dt>
<dd><p>Return the current offset (in bytes) from the beginning of the file.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.TagFile.jump">
<code class="descname">jump</code><span class="sig-paren">(</span><em>offset</em><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.TagFile.jump" title="Permalink to this definition"></a></dt>
<dd><p>Jump back/forward to <em>offset</em>. Use <code class="docutils literal"><span class="pre">jump(0)</span></code> to jump to the
beginning of the file again. Returns <code class="docutils literal"><span class="pre">True</span></code> if a section could
be parsed or <code class="docutils literal"><span class="pre">False</span></code> if not.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.TagFile.section">
<code class="descname">section</code><a class="headerlink" href="#apt_pkg.TagFile.section" title="Permalink to this definition"></a></dt>
<dd><p>This is the current <a class="reference internal" href="#apt_pkg.TagSection" title="apt_pkg.TagSection"><code class="xref py py-class docutils literal"><span class="pre">TagSection()</span></code></a> instance.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="apt_pkg.TagSection">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">TagSection</code><span class="sig-paren">(</span><em>text</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.TagSection" title="Permalink to this definition"></a></dt>
<dd><p>Represent a single section of a debian control file.</p>
<dl class="describe">
<dt>
<code class="descname">section[key]</code></dt>
<dd><p>Return the value of the field at <em>key</em>. If <em>key</em> is not available,
raise <code class="xref py py-exc docutils literal"><span class="pre">KeyError</span></code>.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="descname">key in section</code></dt>
<dd><blockquote>
<div>Return <code class="docutils literal"><span class="pre">True</span></code> if <em>section</em> has a key <em>key</em>, else <code class="docutils literal"><span class="pre">False</span></code>.</div></blockquote>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.7.100.</span></p>
</div>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.TagSection.bytes">
<code class="descname">bytes</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &rarr; int<a class="headerlink" href="#apt_pkg.TagSection.bytes" title="Permalink to this definition"></a></dt>
<dd><p>The number of bytes in the section.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.TagSection.find">
<code class="descname">find</code><span class="sig-paren">(</span><em>key: str</em>, <em>default: str = ''</em><span class="sig-paren">)</span> &rarr; str<a class="headerlink" href="#apt_pkg.TagSection.find" title="Permalink to this definition"></a></dt>
<dd><p>Return the value of the field at the key <em>key</em> if available,
else return <em>default</em>.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.TagSection.find_flag">
<code class="descname">find_flag</code><span class="sig-paren">(</span><em>key: str</em><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.TagSection.find_flag" title="Permalink to this definition"></a></dt>
<dd><p>Find a yes/no value for the key <em>key</em>. An example for such a
field is &#8216;Essential&#8217;.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.TagSection.find_raw">
<code class="descname">find_raw</code><span class="sig-paren">(</span><em>key: str</em>, <em>default: str = ''</em><span class="sig-paren">)</span> &rarr; str<a class="headerlink" href="#apt_pkg.TagSection.find_raw" title="Permalink to this definition"></a></dt>
<dd><p>Similar to <a class="reference internal" href="#apt_pkg.TagSection.find" title="apt_pkg.TagSection.find"><code class="xref py py-meth docutils literal"><span class="pre">find()</span></code></a>, but instead of returning just the value,
it returns the complete field consisting of &#8216;key: value&#8217;.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.TagSection.get">
<code class="descname">get</code><span class="sig-paren">(</span><em>key: str</em>, <em>default: str = ''</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.TagSection.get" title="Permalink to this definition"></a></dt>
<dd><p>Return the value of the field at the key <em>key</em> if available, else
return <em>default</em>.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.TagSection.keys">
<code class="descname">keys</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.TagSection.keys" title="Permalink to this definition"></a></dt>
<dd><p>Return a list of keys in the section.</p>
</dd></dl>

</dd></dl>

<dl class="function">
<dt id="apt_pkg.rewrite_section">
<code class="descclassname">apt_pkg.</code><code class="descname">rewrite_section</code><span class="sig-paren">(</span><em>section: TagSection</em>, <em>order: list</em>, <em>rewrite_list: list</em><span class="sig-paren">)</span> &rarr; str<a class="headerlink" href="#apt_pkg.rewrite_section" title="Permalink to this definition"></a></dt>
<dd><p>Rewrite the section given by <em>section</em> using <em>rewrite_list</em>, and order the
fields according to <em>order</em>.</p>
<p>The parameter <em>order</em> is a <code class="xref py py-class docutils literal"><span class="pre">list</span></code> object containing the names of the
fields in the order they should appear in the rewritten section.
<a class="reference internal" href="#apt_pkg.REWRITE_PACKAGE_ORDER" title="apt_pkg.REWRITE_PACKAGE_ORDER"><code class="xref py py-data docutils literal"><span class="pre">apt_pkg.REWRITE_PACKAGE_ORDER</span></code></a> and
<a class="reference internal" href="#apt_pkg.REWRITE_SOURCE_ORDER" title="apt_pkg.REWRITE_SOURCE_ORDER"><code class="xref py py-data docutils literal"><span class="pre">apt_pkg.REWRITE_SOURCE_ORDER</span></code></a> are two predefined lists for rewriting
package and source sections, respectively.</p>
<p>The parameter <em>rewrite_list</em> is a list of tuples of the form
<code class="docutils literal"><span class="pre">(tag,</span> <span class="pre">newvalue[,</span> <span class="pre">renamed_to])</span></code>, where <em>tag</em> describes the field which
should be changed, <em>newvalue</em> the value which should be inserted or
<code class="docutils literal"><span class="pre">None</span></code> to delete the field, and the optional <em>renamed_to</em> can be used
to rename the field.</p>
</dd></dl>

<dl class="data">
<dt id="apt_pkg.REWRITE_PACKAGE_ORDER">
<code class="descclassname">apt_pkg.</code><code class="descname">REWRITE_PACKAGE_ORDER</code><a class="headerlink" href="#apt_pkg.REWRITE_PACKAGE_ORDER" title="Permalink to this definition"></a></dt>
<dd><p>The order in which the information for binary packages should be rewritten,
i.e. the order in which the fields should appear.</p>
</dd></dl>

<dl class="data">
<dt id="apt_pkg.REWRITE_SOURCE_ORDER">
<code class="descclassname">apt_pkg.</code><code class="descname">REWRITE_SOURCE_ORDER</code><a class="headerlink" href="#apt_pkg.REWRITE_SOURCE_ORDER" title="Permalink to this definition"></a></dt>
<dd><p>The order in which the information for source packages should be rewritten,
i.e. the order in which the fields should appear.</p>
</dd></dl>

</div>
<div class="section" id="dependencies">
<h2>Dependencies<a class="headerlink" href="#dependencies" title="Permalink to this headline"></a></h2>
<dl class="function">
<dt id="apt_pkg.check_dep">
<code class="descclassname">apt_pkg.</code><code class="descname">check_dep</code><span class="sig-paren">(</span><em>pkgver: str</em>, <em>op: str</em>, <em>depver: str</em><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.check_dep" title="Permalink to this definition"></a></dt>
<dd><p>Check that the given requirement is fulfilled; that is, that the version
string given by <em>pkg_ver</em> matches the version string <em>dep_ver</em> under
the condition specified by the operator &#8216;dep_op&#8217; (&lt;,&lt;=,=,&gt;=,&gt;).</p>
<p>Return True if <em>pkg_ver</em> matches <em>dep_ver</em> under the condition &#8216;dep_op&#8217;;
for example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">apt_pkg</span><span class="o">.</span><span class="n">check_dep</span><span class="p">(</span><span class="s">&quot;1.0&quot;</span><span class="p">,</span> <span class="s">&quot;&gt;=&quot;</span><span class="p">,</span> <span class="s">&quot;1&quot;</span><span class="p">)</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

<p>The following two functions provide the ability to parse dependencies. They
use the same format as <a class="reference internal" href="#apt_pkg.Version.depends_list_str" title="apt_pkg.Version.depends_list_str"><code class="xref py py-attr docutils literal"><span class="pre">Version.depends_list_str</span></code></a>.</p>
<dl class="function">
<dt id="apt_pkg.parse_depends">
<code class="descclassname">apt_pkg.</code><code class="descname">parse_depends</code><span class="sig-paren">(</span><em>depends</em>, <em>strip_multiarch=True</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.parse_depends" title="Permalink to this definition"></a></dt>
<dd><p>Parse the string <em>depends</em> which contains dependency information as
specified in Debian Policy, Section 7.1.</p>
<p>Returns a list. The members of this list are lists themselves and contain
one or more tuples in the format <code class="docutils literal"><span class="pre">(package,version,operation)</span></code> for every
&#8216;or&#8217;-option given, e.g.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">apt_pkg</span><span class="o">.</span><span class="n">parse_depends</span><span class="p">(</span><span class="s">&quot;PkgA (&gt;= VerA) | PkgB (&gt;= VerB)&quot;</span><span class="p">)</span>
<span class="go">[[(&#39;PkgA&#39;, &#39;VerA&#39;, &#39;&gt;=&#39;), (&#39;PkgB&#39;, &#39;VerB&#39;, &#39;&gt;=&#39;)]]</span>
</pre></div>
</div>
<p>Note that multiarch dependency information is stripped off by default.
You can force the full dependency info (including the multiarch info)
by passing &#8220;False&#8221; as a additional parameter to this function.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The behavior of this function is different than the behavior of the
old function <code class="xref py py-func docutils literal"><span class="pre">ParseDepends()</span></code>, because the third field
<code class="docutils literal"><span class="pre">operation</span></code> uses <cite>&gt;</cite> instead of <cite>&gt;&gt;</cite> and <cite>&lt;</cite> instead of <cite>&lt;&lt;</cite> which
is specified in control files.</p>
</div>
</dd></dl>

<dl class="function">
<dt id="apt_pkg.parse_src_depends">
<code class="descclassname">apt_pkg.</code><code class="descname">parse_src_depends</code><span class="sig-paren">(</span><em>depends</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.parse_src_depends" title="Permalink to this definition"></a></dt>
<dd><p>Parse the string <em>depends</em> which contains dependency information as
specified in Debian Policy, Section 7.1.</p>
<p>Returns a list. The members of this list are lists themselves and contain
one or more tuples in the format <code class="docutils literal"><span class="pre">(package,version,operation)</span></code> for every
&#8216;or&#8217;-option given, e.g.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">apt_pkg</span><span class="o">.</span><span class="n">parse_depends</span><span class="p">(</span><span class="s">&quot;PkgA (&gt;= VerA) | PkgB (&gt;= VerB)&quot;</span><span class="p">)</span>
<span class="go">[[(&#39;PkgA&#39;, &#39;VerA&#39;, &#39;&gt;=&#39;), (&#39;PkgB&#39;, &#39;VerB&#39;, &#39;&gt;=&#39;)]]</span>
</pre></div>
</div>
<p>Furthemore, this function also supports to limit the architectures, as
used in e.g. Build-Depends:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">apt_pkg</span><span class="o">.</span><span class="n">parse_src_depends</span><span class="p">(</span><span class="s">&quot;a (&gt;= 01) [i386 amd64]&quot;</span><span class="p">)</span>
<span class="go">[[(&#39;a&#39;, &#39;01&#39;, &#39;&gt;=&#39;)]]</span>
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The behavior of this function is different than the behavior of the
old function <code class="xref py py-func docutils literal"><span class="pre">ParseDepends()</span></code>, because the third field
<code class="docutils literal"><span class="pre">operation</span></code> uses <cite>&gt;</cite> instead of <cite>&gt;&gt;</cite> and <cite>&lt;</cite> instead of <cite>&lt;&lt;</cite> which
is specified in control files.</p>
</div>
</dd></dl>

</div>
<div class="section" id="configuration-and-command-line-parsing">
<h2>Configuration and Command-line parsing<a class="headerlink" href="#configuration-and-command-line-parsing" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="apt_pkg.Configuration">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">Configuration</code><a class="headerlink" href="#apt_pkg.Configuration" title="Permalink to this definition"></a></dt>
<dd><p>Provide access to and manipulation of APT&#8217;s configuration which is
used by many classes and functions in this module to define their
behavior. There are options to install recommends, change the root
directory and much more. For an (incomplete) list of available options,
see the <em class="manpage">apt.conf(5)</em> manual page.</p>
<p>The most important Configuration object is the one available by the
module&#8217;s <a class="reference internal" href="#apt_pkg.config" title="apt_pkg.config"><code class="xref py py-attr docutils literal"><span class="pre">apt_pkg.config</span></code></a> attribute. It stores the global
configuration which affects the behavior of most functions and is
initialized by a call to the function <a class="reference internal" href="#apt_pkg.init_config" title="apt_pkg.init_config"><code class="xref py py-func docutils literal"><span class="pre">init_config()</span></code></a>. While
possible, it is generally not needed to create other instances of
this class.</p>
<p>For accessing and manipulating the configuration space, objects
of this type provide an interface which resembles Python mapping
types like <code class="xref py py-class docutils literal"><span class="pre">dict</span></code>.</p>
<dl class="describe">
<dt>
<code class="descname">key in conf</code></dt>
<dd><p>Return <code class="docutils literal"><span class="pre">True</span></code> if <em>conf</em> has a key <em>key</em>, else <code class="docutils literal"><span class="pre">False</span></code>.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="descname">conf[key]</code></dt>
<dd><p>Return the value of the option given key <em>key</em>. If it does not
exist, raise <code class="xref py py-exc docutils literal"><span class="pre">KeyError</span></code>.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="descname">conf[key] = value</code></dt>
<dd><p>Set the option at <em>key</em> to <em>value</em>.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.Configuration.get">
<code class="descname">get</code><span class="sig-paren">(</span><em>key</em><span class="optional">[</span>, <em>default=''</em><span class="optional">]</span><span class="sig-paren">)</span> &rarr; str<a class="headerlink" href="#apt_pkg.Configuration.get" title="Permalink to this definition"></a></dt>
<dd><p>Find the value for the given key and return it. If the given key does
not exist, return <em>default</em> instead.</p>
</dd></dl>

<p>In addition, they provide methods to resemble the interface provided
by the C++ class and some more mapping methods which have been enhanced
to support some more advanced configuration features:</p>
<dl class="method">
<dt id="apt_pkg.Configuration.clear">
<code class="descname">clear</code><span class="sig-paren">(</span><em>key: str</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.Configuration.clear" title="Permalink to this definition"></a></dt>
<dd><p>Remove the option at <em>key</em> and all of its children.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.Configuration.dump">
<code class="descname">dump</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &rarr; str<a class="headerlink" href="#apt_pkg.Configuration.dump" title="Permalink to this definition"></a></dt>
<dd><p>Return a string containing the values in the configuration object,
in the standard <em class="manpage">apt.conf(5)</em> format.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.7.100.</span></p>
</div>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.Configuration.exists">
<code class="descname">exists</code><span class="sig-paren">(</span><em>key</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.Configuration.exists" title="Permalink to this definition"></a></dt>
<dd><p>Check whether an option named <em>key</em> exists in the configuration.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.Configuration.find">
<code class="descname">find</code><span class="sig-paren">(</span><em>key</em><span class="optional">[</span>, <em>default=''</em><span class="optional">]</span><span class="sig-paren">)</span> &rarr; str<a class="headerlink" href="#apt_pkg.Configuration.find" title="Permalink to this definition"></a></dt>
<dd><p>Return the value stored at the option named <em>key</em>, or the value
given by the string <em>default</em> if the option in question is not
set.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.Configuration.find_b">
<code class="descname">find_b</code><span class="sig-paren">(</span><em>key</em><span class="optional">[</span>, <em>default=False</em><span class="optional">]</span><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.Configuration.find_b" title="Permalink to this definition"></a></dt>
<dd><p>Return the boolean value stored at <em>key</em>, or the value given by
the <code class="xref py py-class docutils literal"><span class="pre">bool</span></code> object <em>default</em> if the requested option is
not set.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.Configuration.find_file">
<code class="descname">find_file</code><span class="sig-paren">(</span><em>key</em><span class="optional">[</span>, <em>default=''</em><span class="optional">]</span><span class="sig-paren">)</span> &rarr; str<a class="headerlink" href="#apt_pkg.Configuration.find_file" title="Permalink to this definition"></a></dt>
<dt id="apt_pkg.Configuration.find_dir">
<code class="descname">find_dir</code><span class="sig-paren">(</span><em>key</em><span class="optional">[</span>, <em>default='/'</em><span class="optional">]</span><span class="sig-paren">)</span> &rarr; str<a class="headerlink" href="#apt_pkg.Configuration.find_dir" title="Permalink to this definition"></a></dt>
<dd><p>Locate the given key using <a class="reference internal" href="#apt_pkg.Configuration.find" title="apt_pkg.Configuration.find"><code class="xref py py-meth docutils literal"><span class="pre">find()</span></code></a> and return the path to the
file/directory. This uses a special algorithms which moves upwards
in the configuration space and prepends the values of the options
to the result. These methods are generally used for the options
stored in the &#8216;Dir&#8217; section of the configuration.</p>
<p>As an example of how this works, take a look at the following options
and their values:</p>
<table border="1" class="docutils">
<colgroup>
<col width="34%" />
<col width="66%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Option</th>
<th class="head">Value</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>Dir</td>
<td>/</td>
</tr>
<tr class="row-odd"><td>Dir::Etc</td>
<td>etc/apt/</td>
</tr>
<tr class="row-even"><td>Dir::Etc::main</td>
<td>apt.conf</td>
</tr>
</tbody>
</table>
<p>A call to <a class="reference internal" href="#apt_pkg.Configuration.find_file" title="apt_pkg.Configuration.find_file"><code class="xref py py-meth docutils literal"><span class="pre">find_file()</span></code></a> would now return <code class="docutils literal"><span class="pre">/etc/apt/apt.conf</span></code>
because it prepends the values of &#8220;Dir::Etc&#8221; and &#8220;Dir&#8221; to the value
of &#8220;Dir::Etc::main&#8221;:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">apt_pkg</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">find_file</span><span class="p">(</span><span class="s">&quot;Dir::Etc::main&quot;</span><span class="p">)</span>
<span class="go">&#39;/etc/apt/apt.conf&#39;</span>
</pre></div>
</div>
<p>If the special configuration variable &#8220;RootDir&#8221; is set, this value
would be prepended to every return value, even if the path is already
absolute. If not, the function ends as soon as an absolute path is
created (once an option with a value starting with &#8220;/&#8221; is read).</p>
<p>The method <a class="reference internal" href="#apt_pkg.Configuration.find_dir" title="apt_pkg.Configuration.find_dir"><code class="xref py py-meth docutils literal"><span class="pre">find_dir()</span></code></a> does exactly the same thing as
<a class="reference internal" href="#apt_pkg.Configuration.find_file" title="apt_pkg.Configuration.find_file"><code class="xref py py-meth docutils literal"><span class="pre">find_file()</span></code></a>, but adds a trailing forward slash before
returning the value.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.Configuration.find_i">
<code class="descname">find_i</code><span class="sig-paren">(</span><em>key</em><span class="optional">[</span>, <em>default=0</em><span class="optional">]</span><span class="sig-paren">)</span> &rarr; int<a class="headerlink" href="#apt_pkg.Configuration.find_i" title="Permalink to this definition"></a></dt>
<dd><p>Return the integer value stored at <em>key</em>, or the value given by
the integer <em>default</em> if the requested option is not set.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.Configuration.keys">
<code class="descname">keys</code><span class="sig-paren">(</span><span class="optional">[</span><em>key</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.Configuration.keys" title="Permalink to this definition"></a></dt>
<dd><p>Return a recursive list of all configuration options or, if <em>key</em>
is given, a list of all its children. This method is comparable
to the <strong>keys</strong> method of a mapping object, but additionally
provides the parameter <em>key</em>.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.Configuration.list">
<code class="descname">list</code><span class="sig-paren">(</span><span class="optional">[</span><em>key</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.Configuration.list" title="Permalink to this definition"></a></dt>
<dd><p>Return a non-recursive list of all configuration options. If <em>key</em>
is not given, this returns a list of options like &#8220;Apt&#8221;, &#8220;Dir&#8221;, and
similar. If <em>key</em> is given, a list of the names of its child options
will be returned instead.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.Configuration.my_tag">
<code class="descname">my_tag</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.Configuration.my_tag" title="Permalink to this definition"></a></dt>
<dd><p>Return the tag name of the current tree. Normally (for
<a class="reference internal" href="#apt_pkg.config" title="apt_pkg.config"><code class="xref py py-data docutils literal"><span class="pre">apt_pkg.config</span></code></a>) this is an empty string, but for
sub-trees it is the key of the sub-tree.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.Configuration.set">
<code class="descname">set</code><span class="sig-paren">(</span><em>key: str</em>, <em>value: str</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.Configuration.set" title="Permalink to this definition"></a></dt>
<dd><p>Set the option named <em>key</em> to the value given by the argument
<em>value</em>. It is possible to store objects of the types <code class="xref py py-class docutils literal"><span class="pre">int</span></code>
and <code class="xref py py-class docutils literal"><span class="pre">bool</span></code> by calling <code class="xref py py-func docutils literal"><span class="pre">str()</span></code> on them to convert them
to a string object. They can then be retrieved again by using the
methods <a class="reference internal" href="#apt_pkg.Configuration.find_i" title="apt_pkg.Configuration.find_i"><code class="xref py py-meth docutils literal"><span class="pre">find_i()</span></code></a> or <a class="reference internal" href="#apt_pkg.Configuration.find_b" title="apt_pkg.Configuration.find_b"><code class="xref py py-meth docutils literal"><span class="pre">find_b()</span></code></a>.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.Configuration.subtree">
<code class="descname">subtree</code><span class="sig-paren">(</span><em>key</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.Configuration.subtree" title="Permalink to this definition"></a></dt>
<dd><p>Return a new apt_pkg.Configuration object which starts at the
given option. Example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">apttree</span> <span class="o">=</span> <span class="n">config</span><span class="o">.</span><span class="n">subtree</span><span class="p">(</span><span class="s">&#39;APT&#39;</span><span class="p">)</span>
<span class="n">apttree</span><span class="p">[</span><span class="s">&#39;Install-Suggests&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">config</span><span class="p">[</span><span class="s">&#39;APT::Install-Suggests&#39;</span><span class="p">]</span>
</pre></div>
</div>
<p>The configuration space is shared with the main object which means
that all modifications in one object appear in the other one as
well.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.Configuration.value_list">
<code class="descname">value_list</code><span class="sig-paren">(</span><span class="optional">[</span><em>key</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.Configuration.value_list" title="Permalink to this definition"></a></dt>
<dd><p>This is the opposite of the <a class="reference internal" href="#apt_pkg.Configuration.list" title="apt_pkg.Configuration.list"><code class="xref py py-meth docutils literal"><span class="pre">list()</span></code></a> method in that it returns the
values instead of the option names.</p>
</dd></dl>

</dd></dl>

<dl class="data">
<dt id="apt_pkg.config">
<code class="descclassname">apt_pkg.</code><code class="descname">config</code><a class="headerlink" href="#apt_pkg.config" title="Permalink to this definition"></a></dt>
<dd><p>This variable contains the global configuration which is used by
all classes and functions in this module. After importing the
module, this object should be initialized by calling the module&#8217;s
<a class="reference internal" href="#apt_pkg.init_config" title="apt_pkg.init_config"><code class="xref py py-func docutils literal"><span class="pre">init_config()</span></code></a> function.</p>
</dd></dl>

<dl class="function">
<dt id="apt_pkg.read_config_file">
<code class="descclassname">apt_pkg.</code><code class="descname">read_config_file</code><span class="sig-paren">(</span><em>configuration: Configuration</em>, <em>filename: str</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.read_config_file" title="Permalink to this definition"></a></dt>
<dd><p>Read the configuration file <em>filename</em> and set the appropriate
options in the configuration object <em>configuration</em>.</p>
</dd></dl>

<dl class="function">
<dt id="apt_pkg.read_config_dir">
<code class="descclassname">apt_pkg.</code><code class="descname">read_config_dir</code><span class="sig-paren">(</span><em>configuration</em>, <em>dirname</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.read_config_dir" title="Permalink to this definition"></a></dt>
<dd><p>Read all configuration files in the dir given by &#8216;dirname&#8217; in the
correct order.</p>
</dd></dl>

<dl class="function">
<dt id="apt_pkg.read_config_file_isc">
<code class="descclassname">apt_pkg.</code><code class="descname">read_config_file_isc</code><span class="sig-paren">(</span><em>configuration</em>, <em>filename</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.read_config_file_isc" title="Permalink to this definition"></a></dt>
<dd><p>Read the configuration file <em>filename</em> and set the appropriate
options in the configuration object <em>configuration</em>. This function
requires a slightly different format than APT configuration files,
if you are unsure, do not use it.</p>
</dd></dl>

<dl class="function">
<dt id="apt_pkg.parse_commandline">
<code class="descclassname">apt_pkg.</code><code class="descname">parse_commandline</code><span class="sig-paren">(</span><em>configuration</em>, <em>options</em>, <em>argv</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.parse_commandline" title="Permalink to this definition"></a></dt>
<dd><p>Parse the command line in <em>argv</em> into the configuration space. The
list <em>options</em> contains a list of 3-tuples or 4-tuples in the form:</p>
<div class="highlight-python"><div class="highlight"><pre>(short_option: str, long_option: str, variable: str[, type: str])
</pre></div>
</div>
<p>The element <em>short_option</em> is one character, the <em>long_option</em> element
is the name of the long option, the element <em>variable</em> the name of the
configuration option the result will be stored in and <em>type</em> is one of
&#8216;HasArg&#8217;, &#8216;IntLevel&#8217;, &#8216;Boolean&#8217;, &#8216;InvBoolean&#8217;, &#8216;ConfigFile&#8217;,
&#8216;ArbItem&#8217;. The default type is &#8216;Boolean&#8217;.</p>
<table border="1" class="docutils" id="id2">
<caption><span class="caption-text">Overview of all possible types</span><a class="headerlink" href="#id2" title="Permalink to this table"></a></caption>
<colgroup>
<col width="17%" />
<col width="83%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Type</th>
<th class="head">What happens if the option is given</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>HasArg</td>
<td>The argument given to the option is stored in
the target.</td>
</tr>
<tr class="row-odd"><td>IntLevel</td>
<td>The integer value in the target is increased by one</td>
</tr>
<tr class="row-even"><td>Boolean</td>
<td>The target variable is set to True.</td>
</tr>
<tr class="row-odd"><td>InvBoolean</td>
<td>The target variable is set to False.</td>
</tr>
<tr class="row-even"><td>ConfigFile</td>
<td>The file given as an argument to this option is read
in and all configuration options are added to the
configuration object (APT&#8217;s &#8216;-c&#8217; option).</td>
</tr>
<tr class="row-odd"><td>ArbItem</td>
<td>The option takes an argument <em>key*=*value</em>, and the
configuration option at <em>key</em> is set to the value
<em>value</em> (APT&#8217;s &#8216;-o&#8217; option).</td>
</tr>
</tbody>
</table>
</dd></dl>

</div>
<div class="section" id="locking">
<h2>Locking<a class="headerlink" href="#locking" title="Permalink to this headline"></a></h2>
<p>When working on the global cache, it is important to lock the cache so other
programs do not modify it. This module provides two context managers for
locking the package system or file-based locking.</p>
<dl class="class">
<dt id="apt_pkg.SystemLock">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">SystemLock</code><a class="headerlink" href="#apt_pkg.SystemLock" title="Permalink to this definition"></a></dt>
<dd><p>Context manager for locking the package system. The lock is established
as soon as the method __enter__() is called. It is released when
__exit__() is called. If the lock can not be acquired or can not be
released an exception is raised.</p>
<p>This should be used via the &#8216;with&#8217; statement. For example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">with</span> <span class="n">apt_pkg</span><span class="o">.</span><span class="n">SystemLock</span><span class="p">():</span>
    <span class="o">...</span> <span class="c"># Do your stuff here.</span>
<span class="o">...</span> <span class="c"># Now it&#39;s unlocked again</span>
</pre></div>
</div>
<p>Once the block is left, the lock is released automatically. The object
can be used multiple times:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">lock</span> <span class="o">=</span> <span class="n">apt_pkg</span><span class="o">.</span><span class="n">SystemLock</span><span class="p">()</span>
<span class="k">with</span> <span class="n">lock</span><span class="p">:</span>
    <span class="o">...</span>
<span class="k">with</span> <span class="n">lock</span><span class="p">:</span>
    <span class="o">...</span>
</pre></div>
</div>
</dd></dl>

<dl class="class">
<dt id="apt_pkg.FileLock">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">FileLock</code><span class="sig-paren">(</span><em>filename: str</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.FileLock" title="Permalink to this definition"></a></dt>
<dd><p>Context manager for locking using a file. The lock is established
as soon as the method __enter__() is called. It is released when
__exit__() is called. If the lock can not be acquired or can not be
released, an exception is raised.</p>
<p>This should be used via the &#8216;with&#8217; statement. For example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">with</span> <span class="n">apt_pkg</span><span class="o">.</span><span class="n">FileLock</span><span class="p">(</span><span class="n">filename</span><span class="p">):</span>
    <span class="o">...</span>
</pre></div>
</div>
<p>Once the block is left, the lock is released automatically. The object
can be used multiple times:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">lock</span> <span class="o">=</span> <span class="n">apt_pkg</span><span class="o">.</span><span class="n">FileLock</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span>
<span class="k">with</span> <span class="n">lock</span><span class="p">:</span>
    <span class="o">...</span>
<span class="k">with</span> <span class="n">lock</span><span class="p">:</span>
    <span class="o">...</span>
</pre></div>
</div>
</dd></dl>

<p>For Python versions prior to 2.5, similar functionality is provided by the
following three functions:</p>
<dl class="function">
<dt id="apt_pkg.get_lock">
<code class="descclassname">apt_pkg.</code><code class="descname">get_lock</code><span class="sig-paren">(</span><em>filename: str</em>, <em>errors=False</em><span class="sig-paren">)</span> &rarr; int<a class="headerlink" href="#apt_pkg.get_lock" title="Permalink to this definition"></a></dt>
<dd><p>Create an empty file at the path specified by the parameter <em>filename</em> and
lock it. If this fails and <em>errors</em> is <strong>True</strong>, the function raises an
error. If <em>errors</em> is <strong>False</strong>, the function returns -1.</p>
<p>The lock can be acquired multiple times within the same process, and can be
released by calling <code class="xref py py-func docutils literal"><span class="pre">os.close()</span></code> on the return value which is the file
descriptor of the created file.</p>
</dd></dl>

<dl class="function">
<dt id="apt_pkg.pkgsystem_lock">
<code class="descclassname">apt_pkg.</code><code class="descname">pkgsystem_lock</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.pkgsystem_lock" title="Permalink to this definition"></a></dt>
<dd><p>Lock the global pkgsystem. The lock should be released by calling
<a class="reference internal" href="#apt_pkg.pkgsystem_unlock" title="apt_pkg.pkgsystem_unlock"><code class="xref py py-func docutils literal"><span class="pre">pkgsystem_unlock()</span></code></a> again. If this function is called n-times, the
<a class="reference internal" href="#apt_pkg.pkgsystem_unlock" title="apt_pkg.pkgsystem_unlock"><code class="xref py py-func docutils literal"><span class="pre">pkgsystem_unlock()</span></code></a> function must be called n-times as well to release
all acquired locks.</p>
</dd></dl>

<dl class="function">
<dt id="apt_pkg.pkgsystem_unlock">
<code class="descclassname">apt_pkg.</code><code class="descname">pkgsystem_unlock</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.pkgsystem_unlock" title="Permalink to this definition"></a></dt>
<dd><p>Unlock the global pkgsystem. This reverts the effect of
<a class="reference internal" href="#apt_pkg.pkgsystem_lock" title="apt_pkg.pkgsystem_lock"><code class="xref py py-func docutils literal"><span class="pre">pkgsystem_lock()</span></code></a>.</p>
</dd></dl>

</div>
<div class="section" id="other-classes">
<h2>Other classes<a class="headerlink" href="#other-classes" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="apt_pkg.Cdrom">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">Cdrom</code><a class="headerlink" href="#apt_pkg.Cdrom" title="Permalink to this definition"></a></dt>
<dd><p>A Cdrom object identifies Debian installation media and adds them to
<code class="file docutils literal"><span class="pre">/etc/apt/sources.list</span></code>. The C++ version of this class is used by
the apt-cdrom tool and using this class, you can re-implement apt-cdrom
in Python, see <a class="reference internal" href="../tutorials/apt-cdrom.html"><em>Writing your own apt-cdrom</em></a>.</p>
<p>The class <a class="reference internal" href="apt.cdrom.html#apt.cdrom.Cdrom" title="apt.cdrom.Cdrom"><code class="xref py py-class docutils literal"><span class="pre">apt.cdrom.Cdrom</span></code></a> is a subclass of this class and
provides some additional functionality for higher level use and some
shortcuts for setting some related configuration options.</p>
<p>This class provides two functions which take an instance of
<a class="reference internal" href="apt.progress.base.html#apt.progress.base.CdromProgress" title="apt.progress.base.CdromProgress"><code class="xref py py-class docutils literal"><span class="pre">apt.progress.base.CdromProgress</span></code></a> as their argument.</p>
<dl class="method">
<dt id="apt_pkg.Cdrom.add">
<code class="descname">add</code><span class="sig-paren">(</span><em>progress: apt.progress.base.CdromProgress</em><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.Cdrom.add" title="Permalink to this definition"></a></dt>
<dd><p>Search for a Debian installation media and add it to the list of
sources stored in <code class="file docutils literal"><span class="pre">/etc/apt/sources.list</span></code>. On success, the
boolean value <code class="docutils literal"><span class="pre">True</span></code> is returned. If the process failed or was
canceled by the progress class, <code class="xref py py-exc docutils literal"><span class="pre">SystemError</span></code> is raised or
<code class="docutils literal"><span class="pre">False</span></code> is returned.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.Cdrom.ident">
<code class="descname">ident</code><span class="sig-paren">(</span><em>progress: apt.progress.base.CdromProgress</em><span class="sig-paren">)</span> &rarr; str<a class="headerlink" href="#apt_pkg.Cdrom.ident" title="Permalink to this definition"></a></dt>
<dd><p>Identify the installation media and return a string which describes
its identity. If no media could be identified, <code class="xref py py-exc docutils literal"><span class="pre">SystemError</span></code> is
raised or <code class="docutils literal"><span class="pre">None</span></code> is returned.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="apt_pkg.SourceList">
<em class="property">class </em><code class="descclassname">apt_pkg.</code><code class="descname">SourceList</code><a class="headerlink" href="#apt_pkg.SourceList" title="Permalink to this definition"></a></dt>
<dd><p>Represent the list of sources stored in files such as
<code class="file docutils literal"><span class="pre">/etc/apt/sources.list</span></code>.</p>
<dl class="method">
<dt id="apt_pkg.SourceList.find_index">
<code class="descname">find_index</code><span class="sig-paren">(</span><em>pkgfile: PackageFile</em><span class="sig-paren">)</span> &rarr; IndexFile<a class="headerlink" href="#apt_pkg.SourceList.find_index" title="Permalink to this definition"></a></dt>
<dd><p>Return the <a class="reference internal" href="#apt_pkg.IndexFile" title="apt_pkg.IndexFile"><code class="xref py py-class docutils literal"><span class="pre">IndexFile</span></code></a> object for the <a class="reference internal" href="#apt_pkg.PackageFile" title="apt_pkg.PackageFile"><code class="xref py py-class docutils literal"><span class="pre">PackageFile</span></code></a>
object given by the argument <em>pkgfile</em>. If no index could be found,
return <code class="docutils literal"><span class="pre">None</span></code>.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.SourceList.get_indexes">
<code class="descname">get_indexes</code><span class="sig-paren">(</span><em>acquire: Acquire</em><span class="optional">[</span>, <em>all: bool = False</em><span class="optional">]</span><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.SourceList.get_indexes" title="Permalink to this definition"></a></dt>
<dd><p>Add all indexes to the <a class="reference internal" href="#apt_pkg.Acquire" title="apt_pkg.Acquire"><code class="xref py py-class docutils literal"><span class="pre">Acquire</span></code></a> object given by the argument
<em>acquire</em>. If <em>all</em> is <code class="docutils literal"><span class="pre">True</span></code>, all indexes will be added, otherwise
only the meta indexes (Release files) will be added and others are
fetched as needed.</p>
</dd></dl>

<dl class="method">
<dt id="apt_pkg.SourceList.read_main_list">
<code class="descname">read_main_list</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &rarr; bool<a class="headerlink" href="#apt_pkg.SourceList.read_main_list" title="Permalink to this definition"></a></dt>
<dd><p>Read the files configured in Dir::Etc::SourceList and
Dir::Etc::sourceparts; that is (on normal system),
<code class="file docutils literal"><span class="pre">/etc/apt/sources.list</span></code> and the files in
<code class="file docutils literal"><span class="pre">/etc/apt/sources.list.d</span></code>.</p>
</dd></dl>

<dl class="attribute">
<dt id="apt_pkg.SourceList.list">
<code class="descname">list</code><a class="headerlink" href="#apt_pkg.SourceList.list" title="Permalink to this definition"></a></dt>
<dd><p>A list of <a class="reference internal" href="#apt_pkg.MetaIndex" title="apt_pkg.MetaIndex"><code class="xref py py-class docutils literal"><span class="pre">MetaIndex</span></code></a> objects.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="string-functions">
<h2>String functions<a class="headerlink" href="#string-functions" title="Permalink to this headline"></a></h2>
<dl class="function">
<dt id="apt_pkg.base64_encode">
<code class="descclassname">apt_pkg.</code><code class="descname">base64_encode</code><span class="sig-paren">(</span><em>value: bytes</em><span class="sig-paren">)</span> &rarr; str<a class="headerlink" href="#apt_pkg.base64_encode" title="Permalink to this definition"></a></dt>
<dd><p>Encode the given bytes string (which may not contain a null byte)
using base64, for example, on Python 3 and newer:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">apt_pkg</span><span class="o">.</span><span class="n">base64_encode</span><span class="p">(</span><span class="n">b</span><span class="s">&quot;A&quot;</span><span class="p">)</span>
<span class="go">&#39;QQ==&#39;</span>
</pre></div>
</div>
<p>on Python versions prior to 3, the &#8216;b&#8217; before the string has to be
omitted.</p>
</dd></dl>

<dl class="function">
<dt id="apt_pkg.check_domain_list">
<code class="descclassname">apt_pkg.</code><code class="descname">check_domain_list</code><span class="sig-paren">(</span><em>host</em>, <em>list</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.check_domain_list" title="Permalink to this definition"></a></dt>
<dd><p>See if the host name given by <em>host</em> is one of the domains given in the
comma-separated list <em>list</em> or a subdomain of one of them.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">apt_pkg</span><span class="o">.</span><span class="n">check_domain_list</span><span class="p">(</span><span class="s">&quot;alioth.debian.org&quot;</span><span class="p">,</span><span class="s">&quot;debian.net,debian.org&quot;</span><span class="p">)</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="apt_pkg.dequote_string">
<code class="descclassname">apt_pkg.</code><code class="descname">dequote_string</code><span class="sig-paren">(</span><em>string: str</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.dequote_string" title="Permalink to this definition"></a></dt>
<dd><p>Dequote the string specified by the parameter <em>string</em>, e.g.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">apt_pkg</span><span class="o">.</span><span class="n">dequote_string</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%61%</span><span class="s">70</span><span class="si">%74%</span><span class="s">20is</span><span class="si">%20c</span><span class="s">ool&quot;</span><span class="p">)</span>
<span class="go">&#39;apt is cool&#39;</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="apt_pkg.quote_string">
<code class="descclassname">apt_pkg.</code><code class="descname">quote_string</code><span class="sig-paren">(</span><em>string</em>, <em>repl</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.quote_string" title="Permalink to this definition"></a></dt>
<dd><p>Escape the string <em>string</em>, replacing any character not allowed in a URL
or specified by <em>repl</em> with its ASCII value preceded by a percent sign
(so for example &#8216; &#8216; becomes &#8216;%20&#8217;).</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">apt_pkg</span><span class="o">.</span><span class="n">quote_string</span><span class="p">(</span><span class="s">&quot;apt is cool&quot;</span><span class="p">,</span><span class="s">&quot;apt&quot;</span><span class="p">)</span>
<span class="go">&#39;%61%70%74%20is%20cool&#39;</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="apt_pkg.size_to_str">
<code class="descclassname">apt_pkg.</code><code class="descname">size_to_str</code><span class="sig-paren">(</span><em>size: int</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.size_to_str" title="Permalink to this definition"></a></dt>
<dd><p>Return a string describing the size in a human-readable manner using
SI prefix and base-10 units, e.g. &#8216;1k&#8217; for 1000, &#8216;1M&#8217; for 1000000, etc.</p>
<p>Example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">apt_pkg</span><span class="o">.</span><span class="n">size_to_str</span><span class="p">(</span><span class="mi">10000</span><span class="p">)</span>
<span class="go">&#39;10.0k&#39;</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="apt_pkg.string_to_bool">
<code class="descclassname">apt_pkg.</code><code class="descname">string_to_bool</code><span class="sig-paren">(</span><em>input</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.string_to_bool" title="Permalink to this definition"></a></dt>
<dd><p>Parse the string <em>input</em> and return one of <strong>-1</strong>, <strong>0</strong>, <strong>1</strong>.</p>
<table border="1" class="docutils" id="id3">
<caption><span class="caption-text">Return values</span><a class="headerlink" href="#id3" title="Permalink to this table"></a></caption>
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Value</th>
<th class="head">Meaning</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>-1</td>
<td>The string <em>input</em> is not recognized.</td>
</tr>
<tr class="row-odd"><td>0</td>
<td>The string <em>input</em> evaluates to <strong>False</strong>.</td>
</tr>
<tr class="row-even"><td>+1</td>
<td>The string <em>input</em> evaluates to <strong>True</strong>.</td>
</tr>
</tbody>
</table>
<p>Example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">apt_pkg</span><span class="o">.</span><span class="n">string_to_bool</span><span class="p">(</span><span class="s">&quot;yes&quot;</span><span class="p">)</span>
<span class="go">1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">apt_pkg</span><span class="o">.</span><span class="n">string_to_bool</span><span class="p">(</span><span class="s">&quot;no&quot;</span><span class="p">)</span>
<span class="go">0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">apt_pkg</span><span class="o">.</span><span class="n">string_to_bool</span><span class="p">(</span><span class="s">&quot;not-recognized&quot;</span><span class="p">)</span>
<span class="go">-1</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="apt_pkg.str_to_time">
<code class="descclassname">apt_pkg.</code><code class="descname">str_to_time</code><span class="sig-paren">(</span><em>rfc_time</em><span class="sig-paren">)</span><a class="headerlink" href="#apt_pkg.str_to_time" title="Permalink to this definition"></a></dt>
<dd><p>Convert the <span class="target" id="index-1"></span><a class="rfc reference external" href="https://tools.ietf.org/html/rfc1123.html"><strong>RFC 1123</strong></a> conforming string <em>rfc_time</em> to the unix time, and
return the integer. This is the opposite of <code class="xref py py-func docutils literal"><span class="pre">TimeRFC1123()</span></code>.</p>
<p>Example:</p>
<div class="highlight-python"><div class="highlight"><pre>&gt;&gt; apt_pkg.str_to_time(&#39;Thu, 01 Jan 1970 00:00:00 GMT&#39;)
0
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="apt_pkg.time_rfc1123">
<code class="descclassname">apt_pkg.</code><code class="descname">time_rfc1123</code><span class="sig-paren">(</span><em>seconds: int</em><span class="sig-paren">)</span> &rarr; str<a class="headerlink" href="#apt_pkg.time_rfc1123" title="Permalink to this definition"></a></dt>
<dd><p>Format the unix time specified by the integer <em>seconds</em>, according to the
requirements of <span class="target" id="index-2"></span><a class="rfc reference external" href="https://tools.ietf.org/html/rfc1123.html"><strong>RFC 1123</strong></a>.</p>
<p>Example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">apt_pkg</span><span class="o">.</span><span class="n">time_rfc1123</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
<span class="go">&#39;Thu, 01 Jan 1970 00:00:00 GMT&#39;</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="apt_pkg.time_to_str">
<code class="descclassname">apt_pkg.</code><code class="descname">time_to_str</code><span class="sig-paren">(</span><em>seconds: int</em><span class="sig-paren">)</span> &rarr; str<a class="headerlink" href="#apt_pkg.time_to_str" title="Permalink to this definition"></a></dt>
<dd><p>Format a given duration in a human-readable manner. The parameter <em>seconds</em>
refers to a number of seconds, given as an integer. The return value is a
string with a unit like &#8216;s&#8217; for seconds.</p>
<p>Example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">apt_pkg</span><span class="o">.</span><span class="n">time_to_str</span><span class="p">(</span><span class="mi">3601</span><span class="p">)</span>
<span class="go">&#39;1h0min1s&#39;</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="apt_pkg.upstream_version">
<code class="descclassname">apt_pkg.</code><code class="descname">upstream_version</code><span class="sig-paren">(</span><em>version: str</em><span class="sig-paren">)</span> &rarr; str<a class="headerlink" href="#apt_pkg.upstream_version" title="Permalink to this definition"></a></dt>
<dd><p>Return the upstream version for the Debian package version given by
<em>version</em>.</p>
</dd></dl>

<dl class="function">
<dt id="apt_pkg.uri_to_filename">
<code class="descclassname">apt_pkg.</code><code class="descname">uri_to_filename</code><span class="sig-paren">(</span><em>uri: str</em><span class="sig-paren">)</span> &rarr; str<a class="headerlink" href="#apt_pkg.uri_to_filename" title="Permalink to this definition"></a></dt>
<dd><p>Take a string <em>uri</em> as parameter and return a filename which can be used to
store the file, based on the URI.</p>
<p>Example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">apt_pkg</span><span class="o">.</span><span class="n">uri_to_filename</span><span class="p">(</span><span class="s">&#39;http://debian.org/index.html&#39;</span><span class="p">)</span>
<span class="go">&#39;debian.org_index.html&#39;</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="apt_pkg.version_compare">
<code class="descclassname">apt_pkg.</code><code class="descname">version_compare</code><span class="sig-paren">(</span><em>a: str</em>, <em>b: str</em><span class="sig-paren">)</span> &rarr; int<a class="headerlink" href="#apt_pkg.version_compare" title="Permalink to this definition"></a></dt>
<dd><p>Compare two versions, <em>a</em> and <em>b</em>, and return an integer value which has
the same meaning as the built-in <code class="xref py py-func docutils literal"><span class="pre">cmp()</span></code> function&#8217;s return value has,
see the following table for details.</p>
<table border="1" class="docutils" id="id4">
<caption><span class="caption-text">Return values</span><a class="headerlink" href="#id4" title="Permalink to this table"></a></caption>
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Value</th>
<th class="head">Meaning</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>&gt; 0</td>
<td>The version <em>a</em> is greater than version <em>b</em>.</td>
</tr>
<tr class="row-odd"><td>= 0</td>
<td>Both versions are equal.</td>
</tr>
<tr class="row-even"><td>&lt; 0</td>
<td>The version <em>a</em> is less than version <em>b</em>.</td>
</tr>
</tbody>
</table>
</dd></dl>

</div>
<div class="section" id="module-constants">
<h2>Module Constants<a class="headerlink" href="#module-constants" title="Permalink to this headline"></a></h2>
<div class="section" id="package-states">
<span id="curstates"></span><h3>Package States<a class="headerlink" href="#package-states" title="Permalink to this headline"></a></h3>
<dl class="data">
<dt id="apt_pkg.CURSTATE_CONFIG_FILES">
<code class="descclassname">apt_pkg.</code><code class="descname">CURSTATE_CONFIG_FILES</code><a class="headerlink" href="#apt_pkg.CURSTATE_CONFIG_FILES" title="Permalink to this definition"></a></dt>
<dd><p>Only the configuration files of the package exist on the system.</p>
</dd></dl>

<dl class="data">
<dt id="apt_pkg.CURSTATE_HALF_CONFIGURED">
<code class="descclassname">apt_pkg.</code><code class="descname">CURSTATE_HALF_CONFIGURED</code><a class="headerlink" href="#apt_pkg.CURSTATE_HALF_CONFIGURED" title="Permalink to this definition"></a></dt>
<dd><p>The package is unpacked and configuration has been started, but not
yet completed.</p>
</dd></dl>

<dl class="data">
<dt id="apt_pkg.CURSTATE_HALF_INSTALLED">
<code class="descclassname">apt_pkg.</code><code class="descname">CURSTATE_HALF_INSTALLED</code><a class="headerlink" href="#apt_pkg.CURSTATE_HALF_INSTALLED" title="Permalink to this definition"></a></dt>
<dd><p>The installation of the package has been started, but not completed.</p>
</dd></dl>

<dl class="data">
<dt id="apt_pkg.CURSTATE_INSTALLED">
<code class="descclassname">apt_pkg.</code><code class="descname">CURSTATE_INSTALLED</code><a class="headerlink" href="#apt_pkg.CURSTATE_INSTALLED" title="Permalink to this definition"></a></dt>
<dd><p>The package is unpacked, configured and OK.</p>
</dd></dl>

<dl class="data">
<dt id="apt_pkg.CURSTATE_NOT_INSTALLED">
<code class="descclassname">apt_pkg.</code><code class="descname">CURSTATE_NOT_INSTALLED</code><a class="headerlink" href="#apt_pkg.CURSTATE_NOT_INSTALLED" title="Permalink to this definition"></a></dt>
<dd><p>The package is not installed.</p>
</dd></dl>

<dl class="data">
<dt id="apt_pkg.CURSTATE_UNPACKED">
<code class="descclassname">apt_pkg.</code><code class="descname">CURSTATE_UNPACKED</code><a class="headerlink" href="#apt_pkg.CURSTATE_UNPACKED" title="Permalink to this definition"></a></dt>
<dd><p>The package is unpacked, but not configured.</p>
</dd></dl>

</div>
<div class="section" id="installed-states">
<span id="inststates"></span><h3>Installed states<a class="headerlink" href="#installed-states" title="Permalink to this headline"></a></h3>
<dl class="data">
<dt id="apt_pkg.INSTSTATE_HOLD">
<code class="descclassname">apt_pkg.</code><code class="descname">INSTSTATE_HOLD</code><a class="headerlink" href="#apt_pkg.INSTSTATE_HOLD" title="Permalink to this definition"></a></dt>
<dd><p>The package is put on hold.</p>
</dd></dl>

<dl class="data">
<dt id="apt_pkg.INSTSTATE_HOLD_REINSTREQ">
<code class="descclassname">apt_pkg.</code><code class="descname">INSTSTATE_HOLD_REINSTREQ</code><a class="headerlink" href="#apt_pkg.INSTSTATE_HOLD_REINSTREQ" title="Permalink to this definition"></a></dt>
<dd><p>The package is put on hold, but broken and has to be reinstalled.</p>
</dd></dl>

<dl class="data">
<dt id="apt_pkg.INSTSTATE_OK">
<code class="descclassname">apt_pkg.</code><code class="descname">INSTSTATE_OK</code><a class="headerlink" href="#apt_pkg.INSTSTATE_OK" title="Permalink to this definition"></a></dt>
<dd><p>The package is OK.</p>
</dd></dl>

<dl class="data">
<dt id="apt_pkg.INSTSTATE_REINSTREQ">
<code class="descclassname">apt_pkg.</code><code class="descname">INSTSTATE_REINSTREQ</code><a class="headerlink" href="#apt_pkg.INSTSTATE_REINSTREQ" title="Permalink to this definition"></a></dt>
<dd><p>The package is broken and has to be reinstalled.</p>
</dd></dl>

</div>
<div class="section" id="priorities">
<span id="id1"></span><h3>Priorities<a class="headerlink" href="#priorities" title="Permalink to this headline"></a></h3>
<dl class="data">
<dt id="apt_pkg.PRI_EXTRA">
<code class="descclassname">apt_pkg.</code><code class="descname">PRI_EXTRA</code><a class="headerlink" href="#apt_pkg.PRI_EXTRA" title="Permalink to this definition"></a></dt>
<dd><p>The integer representation of the priority &#8216;extra&#8217;.</p>
</dd></dl>

<dl class="data">
<dt id="apt_pkg.PRI_IMPORTANT">
<code class="descclassname">apt_pkg.</code><code class="descname">PRI_IMPORTANT</code><a class="headerlink" href="#apt_pkg.PRI_IMPORTANT" title="Permalink to this definition"></a></dt>
<dd><p>The integer representation of the priority &#8216;important&#8217;.</p>
</dd></dl>

<dl class="data">
<dt id="apt_pkg.PRI_OPTIONAL">
<code class="descclassname">apt_pkg.</code><code class="descname">PRI_OPTIONAL</code><a class="headerlink" href="#apt_pkg.PRI_OPTIONAL" title="Permalink to this definition"></a></dt>
<dd><p>The integer representation of the priority &#8216;optional&#8217;.</p>
</dd></dl>

<dl class="data">
<dt id="apt_pkg.PRI_REQUIRED">
<code class="descclassname">apt_pkg.</code><code class="descname">PRI_REQUIRED</code><a class="headerlink" href="#apt_pkg.PRI_REQUIRED" title="Permalink to this definition"></a></dt>
<dd><p>The integer representation of the priority &#8216;required&#8217;.</p>
</dd></dl>

<dl class="data">
<dt id="apt_pkg.PRI_STANDARD">
<code class="descclassname">apt_pkg.</code><code class="descname">PRI_STANDARD</code><a class="headerlink" href="#apt_pkg.PRI_STANDARD" title="Permalink to this definition"></a></dt>
<dd><p>The integer representation of the priority &#8216;standard&#8217;.</p>
</dd></dl>

</div>
<div class="section" id="package-selection-states">
<span id="selstates"></span><h3>Package selection states<a class="headerlink" href="#package-selection-states" title="Permalink to this headline"></a></h3>
<dl class="data">
<dt id="apt_pkg.SELSTATE_DEINSTALL">
<code class="descclassname">apt_pkg.</code><code class="descname">SELSTATE_DEINSTALL</code><a class="headerlink" href="#apt_pkg.SELSTATE_DEINSTALL" title="Permalink to this definition"></a></dt>
<dd><p>The package is selected for deinstallation.</p>
</dd></dl>

<dl class="data">
<dt id="apt_pkg.SELSTATE_HOLD">
<code class="descclassname">apt_pkg.</code><code class="descname">SELSTATE_HOLD</code><a class="headerlink" href="#apt_pkg.SELSTATE_HOLD" title="Permalink to this definition"></a></dt>
<dd><p>The package is marked to be on hold and will not be modified.</p>
</dd></dl>

<dl class="data">
<dt id="apt_pkg.SELSTATE_INSTALL">
<code class="descclassname">apt_pkg.</code><code class="descname">SELSTATE_INSTALL</code><a class="headerlink" href="#apt_pkg.SELSTATE_INSTALL" title="Permalink to this definition"></a></dt>
<dd><p>The package is selected for installation.</p>
</dd></dl>

<dl class="data">
<dt id="apt_pkg.SELSTATE_PURGE">
<code class="descclassname">apt_pkg.</code><code class="descname">SELSTATE_PURGE</code><a class="headerlink" href="#apt_pkg.SELSTATE_PURGE" title="Permalink to this definition"></a></dt>
<dd><p>The package is selected to be purged.</p>
</dd></dl>

<dl class="data">
<dt id="apt_pkg.SELSTATE_UNKNOWN">
<code class="descclassname">apt_pkg.</code><code class="descname">SELSTATE_UNKNOWN</code><a class="headerlink" href="#apt_pkg.SELSTATE_UNKNOWN" title="Permalink to this definition"></a></dt>
<dd><p>The package is in an unknown state.</p>
</dd></dl>

</div>
<div class="section" id="build-information">
<h3>Build information<a class="headerlink" href="#build-information" title="Permalink to this headline"></a></h3>
<dl class="data">
<dt id="apt_pkg.DATE">
<code class="descclassname">apt_pkg.</code><code class="descname">DATE</code><a class="headerlink" href="#apt_pkg.DATE" title="Permalink to this definition"></a></dt>
<dd><p>The date on which this extension has been compiled.</p>
</dd></dl>

<dl class="data">
<dt id="apt_pkg.LIB_VERSION">
<code class="descclassname">apt_pkg.</code><code class="descname">LIB_VERSION</code><a class="headerlink" href="#apt_pkg.LIB_VERSION" title="Permalink to this definition"></a></dt>
<dd><p>The version of the apt_pkg library. This is <strong>not</strong> the version of apt,
nor the version of python-apt.</p>
</dd></dl>

<dl class="data">
<dt id="apt_pkg.TIME">
<code class="descclassname">apt_pkg.</code><code class="descname">TIME</code><a class="headerlink" href="#apt_pkg.TIME" title="Permalink to this definition"></a></dt>
<dd><p>The time this extension has been built.</p>
</dd></dl>

<dl class="data">
<dt id="apt_pkg.VERSION">
<code class="descclassname">apt_pkg.</code><code class="descname">VERSION</code><a class="headerlink" href="#apt_pkg.VERSION" title="Permalink to this definition"></a></dt>
<dd><p>The version of apt (not of python-apt).</p>
</dd></dl>

</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../contents.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#"><code class="docutils literal"><span class="pre">apt_pkg</span></code> &#8212; The low-level bindings for apt-pkg</a><ul>
<li><a class="reference internal" href="#module-initialization">Module Initialization</a></li>
<li><a class="reference internal" href="#working-with-the-cache">Working with the cache</a><ul>
<li><a class="reference internal" href="#managing-the-cache-with-depcache">Managing the cache with <code class="docutils literal"><span class="pre">DepCache</span></code></a></li>
<li><a class="reference internal" href="#installing-with-packagemanager">Installing with <code class="docutils literal"><span class="pre">PackageManager</span></code></a></li>
<li><a class="reference internal" href="#installation-ordering-with-orderlist">Installation ordering with <code class="docutils literal"><span class="pre">OrderList</span></code></a></li>
<li><a class="reference internal" href="#improve-performance-with-actiongroup">Improve performance with <code class="docutils literal"><span class="pre">ActionGroup</span></code></a></li>
<li><a class="reference internal" href="#resolving-dependencies-with-problemresolver">Resolving Dependencies with <code class="docutils literal"><span class="pre">ProblemResolver</span></code></a></li>
<li><a class="reference internal" href="#group-of-packages-with-the-same-name"><code class="docutils literal"><span class="pre">Group</span></code> of packages with the same name</a></li>
<li><a class="reference internal" href="#package-information"><code class="docutils literal"><span class="pre">Package</span></code> information</a><ul>
<li><a class="reference internal" href="#example">Example:</a></li>
</ul>
</li>
<li><a class="reference internal" href="#version"><code class="docutils literal"><span class="pre">Version</span></code></a></li>
<li><a class="reference internal" href="#dependency"><code class="docutils literal"><span class="pre">Dependency</span></code></a><ul>
<li><a class="reference internal" href="#example-find-all-missing-dependencies">Example: Find all missing dependencies</a></li>
</ul>
</li>
<li><a class="reference internal" href="#description"><code class="docutils literal"><span class="pre">Description</span></code></a></li>
<li><a class="reference internal" href="#package-pinning-with-policy">Package Pinning with <code class="docutils literal"><span class="pre">Policy</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#index-files">Index Files</a></li>
<li><a class="reference internal" href="#records-release-files-packages-sources">Records (Release files, Packages, Sources)</a></li>
<li><a class="reference internal" href="#the-acquire-interface">The Acquire interface</a></li>
<li><a class="reference internal" href="#hashes">Hashes</a></li>
<li><a class="reference internal" href="#debian-control-files">Debian control files</a></li>
<li><a class="reference internal" href="#dependencies">Dependencies</a></li>
<li><a class="reference internal" href="#configuration-and-command-line-parsing">Configuration and Command-line parsing</a></li>
<li><a class="reference internal" href="#locking">Locking</a></li>
<li><a class="reference internal" href="#other-classes">Other classes</a></li>
<li><a class="reference internal" href="#string-functions">String functions</a></li>
<li><a class="reference internal" href="#module-constants">Module Constants</a><ul>
<li><a class="reference internal" href="#package-states">Package States</a></li>
<li><a class="reference internal" href="#installed-states">Installed states</a></li>
<li><a class="reference internal" href="#priorities">Priorities</a></li>
<li><a class="reference internal" href="#package-selection-states">Package selection states</a></li>
<li><a class="reference internal" href="#build-information">Build information</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<div class="relations">
<h3>Related Topics</h3>
<ul>
  <li><a href="../contents.html">Documentation overview</a><ul>
  <li><a href="index.html">Python APT Library</a><ul>
      <li>Previous: <a href="index.html" title="previous chapter">Python APT Library</a></li>
      <li>Next: <a href="apt_inst.html" title="next chapter"><code class="docutils literal"><span class="pre">apt_inst</span></code> - Working with local Debian packages</a></li>
  </ul></li>
  </ul></li>
</ul>
</div>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../_sources/library/apt_pkg.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer">
      &copy;2009-2010, Julian Andres Klode <jak@debian.org>.
      
      |
      Powered by <a href="http://sphinx-doc.org/">Sphinx 1.3.4</a>
      &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.6</a>
      
      |
      <a href="../_sources/library/apt_pkg.txt"
          rel="nofollow">Page source</a>
    </div>

    

    
  </body>
</html>